cancel
Showing results for 
Search instead for 
Did you mean: 

Generating 1Mhz CLK signal using TIMER

leventeyigel52
Associate II
Posted on March 14, 2012 at 13:30

The original post was too long to process during our migration. Please click on the attachment to read the original post.
1 REPLY 1
Posted on March 14, 2012 at 14:47

You have ridiculous values for period and prescale, and set CCR values exceeding 16-bit, ie >65535.

From 36 MHz, You get 1 MHz by dividing 36 by 6 twice :

  TIM_TimeBaseStructure.TIM_Period = 6-1;

  TIM_TimeBaseStructure.TIM_Prescaler = 6-1;

Other values will work, just do the math.

Personally, I'd use PWM mode, and set the width to 3 (ie 50/50), no interrupts required. Toggle mode might work too.

Also, you can't possibly interrupt at a 1 MHz rate, the part will simply saturate.

The CCR advance trick only works well for a 65535 period value, as the CC interrupts also get triggered by the update, as I recall.

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