cancel
Showing results for 
Search instead for 
Did you mean: 

Setting TIMER as 16MHz [STM32]

AE104
Senior

Hello,

I want to get timer frequency between 16MHz to 20MHz. So I picked the TIM4 and set it with internal clock. Based on the datasheet (STM32F767), the timer belongs to APB1 bus. When I set the main clock frequency as 216Mhz, I expect to get 108MHz timer clock. For getting, 16MHz output, I set the prescaler 7-1 and counter period as 1-1. For observing the timer frequency, I enabled one of the pin as GPIO (PC7) and wrote toggling function in a while loop. When I measure from the oscilloscope, I see 1.642MHz signal. Does anyone have an idea how I can get 16MHz signal?

Thank you

2 REPLIES 2

Need to be willing to run the F7 at 192 MHz, so you can get a workable set of integer dividers.

APB1 @ 96 MHz

>> I set the prescaler 7-1 and counter period as 1-1.

You don't do it that way, you really want the prescaler to be the smaller of the two.

@ 96MHz Prescaler=0, Period=6-1

You can't interrupt at high speeds.

Toggling will half the frequency.

Try 50/50 PWM Duty, Pulse = 3

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

> counter period as 1-1.

0690X000009k4nPQAQ.png

JW