Skip to main content
leventeyigel52
Associate III
March 14, 2012
Question

Generating 1Mhz CLK signal using TIMER

  • March 14, 2012
  • 1 reply
  • 517 views
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.
    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    March 14, 2012
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..