2012-03-14 05:30 AM
2012-03-14 06:47 AM
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.