2013-05-21 11:37 AM
I want to measure the frequency of an input signal with the STM32F4 Discovery Board. But i want to configure Timer 1 (in mode Input capture) to generate an interrupt every 50 Hz (or any other fixed value). How can i do this ???
Thank you.2013-05-21 11:55 AM
So set up the timebase period and prescaler to divide the source clock down to 50 Hz. Factor in a manner of your choosing. Enable the Update interrupt
For an 84 MHz TIMCLK Prescale = 28 - 1; Period = 60000 - 1; Your input compare will be a modulo 60000 value now. Ticks will be in 3 MHz units, ie 333.333 ns, update at 20 ms (50 Hz) 50 * 28 * 60000 = 840000002018-06-11 02:58 AM
HELLO
Turvey.Clive
I want to ask you how to know the value of TIMCLK please ??
I activated timer 14 for mode compare output no output mode and I want to set its interrupt every 100 ms
thank you for your reply in advance
2018-06-11 03:07 AM
'
But i want to configure Timer 1 (in mode Input capture) to generate an interrupt every 50 Hz (or any other fixed value). '
since you are using the input capture mode to generate interrupts, you just need to configure the timer to interrupt on every rising / falling edge and feed it a 50Hz signal.
'How can i do this ???'
by coding to the datasheet.
the other approach highlighted earlier is incorrect.
2018-06-11 03:14 AM
henry.****
I want to ask you how to know the value of TIMCLK please ??
2018-06-11 06:41 AM
Review the Clock Tree in the Reference Manual, the TIMCLK is derived from the APB Clock the TIM being used is attached too.
ie if APB1, in all cases other than the DIV1 setting the TIMCLK = APB1CLK * 2;
2018-06-11 03:57 PM
For what you are trying to do, the value in timclk is irrelevant - basically the in out pulse train determines the maximum frequency of (input capture) interrupts.
If you insist, two easy ways to know the value of timclk:
1. Go through the datasheet and your code.
2. Run your code in a debugger and inspect the register.
2018-06-14 01:27 AM
Turvey.Clive
For an 84 MHz TIMCLK Prescale = 28 - 1;
Period = 60000 - 1; Your input compare will be a modulo 60000 value now. Ticks will be in 3 MHz units, ie 333 ns, update at 20 ms (50 Hz) 50 * 28 * 60000 = 84000000In cubMX in the configuration shall we write 28 as prescale value or 27 ?? same as periode value please ??
thank you for your reply