1 year, 1 month ago.

Sample Code for Measure frequency upto 10MHZ in MBED Nucleus Board (STM32F104)

Sample Code for Measure frequency upto 10MHZ in MBED Nucleus Board (STM32F104) for timer 2 channel 3....?

Comment on this question

2 Answers

1 year, 1 month ago.

Please refer my notebook.
I don't know STM32F104F but I hope you can use similar configuration for your CPU.

Okay this works for PA_0 [Channel1, timer2] but cou;ld not work for channel3, timer2. Any idea? what changes needs to be done?

posted by sandeep rai 27 Aug 2018
1 year, 1 month ago.

Did you mean STM32F401? This is usually called pulse counting or maybe frequency counting. That micro has an 84MHz clock so 10MHz is a screaming fast signal to try to measure. Basically impossible to do this in software. This has to be offloaded to hardware. The best way I can think of is to configure a timer to work with an external clock input. This external 10MHz signal then clocks your timer and software can check the accumulated timer value periodically at a fixed time interval. Of course only works if the micro timer hardware supports external clock input - it appears timers on this micro do support this. This requires that you dig down into the ST HAL layers.

You can also check the STM forums, I'm sure there are some examples of setting this up in HAL. I don't immediately see anything from the mbed import wizard that fits the bill here. And of course read the HAL libraries, they may even have a function to help setup timers in this mode.