If you want to measure the frequency of a signal that fast then you're probably best off using the hardware that's built into the STM32F4.
There's a page on how to do that here: http://www.espruino.com/STM32+Peripherals
It pretty much walks you through all the code you need to use the hardware to count the amount of times the pin changes state - then you could just sample and reset that register every second using setInterval and you've got yourself a frequency measurement in Hz.
© Espruino, powered by microcosm.
Report a problem