Report
4 months, 1 week 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

4 months, 1 week ago.

Please refer my notebook.
/users/kenjiArai/notebook/frequency-counters/
/users/kenjiArai/notebook/simple-frequency-counter/
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
4 months, 1 week 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.

https://www.st.com/content/ccc/resource/technical/document/reference_manual/5d/b1/ef/b2/a1/66/40/80/DM00096844.pdf/files/DM00096844.pdf/jcr:content/translations/en.DM00096844.pdf

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.


To post an answer, please log in.