cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring low frequency and duy cycle of PWM with STM32F407-DİSC .

EÇABU.1
Associate II

I want to measure duty cycle and frequency with STM32F407-Disc.

I know to measure high frequency PPWM with input capture mode.STM32F407 allow to measure 1.5KHz frequency pwm .But I want to learn how can I measure dutycycle and frequency of 1 HZ pwm .Or lower frequency.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Per the reference manual, the prescaler is 16 bits.

168 MHz / 2^16 / 2^16 = 0.04 Hz. That is the frequency your timer updates, so anything quicker than that you should be able to capture with standard IC edge captures.

For low frequency signals, often monitoring the pin periodically gives sufficient resolution.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
TDK
Guru

Lots of ways to do this.

Increase the timer prescaler such that the timer period is larger than the period you want to capture. You should have more than enough room to capture 1 Hz. At the highest timer frequency of 168 MHz, you can use the 16-bit prescaler and 16-bit timer to capture as low as 0.04 Hz.

You can also use a 32-bit timer in conjunction with the prescaler to get even lower frequency captures.

If you feel a post has answered your question, please click "Accept as Solution".
EÇABU.1
Associate II

Thank you for response.I understand it.But i want to ask other question.What is the range of 16-bit prescaler.Is it 0 to 65536? I did not calculated the 0.04Hz using 16 bit timer and 16 bit prescaler.How did you that?.

168Mhz/65536=2563Hz

2563/Prescalaer =?

TDK
Guru

Per the reference manual, the prescaler is 16 bits.

168 MHz / 2^16 / 2^16 = 0.04 Hz. That is the frequency your timer updates, so anything quicker than that you should be able to capture with standard IC edge captures.

For low frequency signals, often monitoring the pin periodically gives sufficient resolution.

If you feel a post has answered your question, please click "Accept as Solution".
EÇABU.1
Associate II

Thank you.Although I did the calculation correctly, I was confused. I thought that I could not find the correct result. When the result came out 0.039.