This is basic math: If your SMCLK runs at 1MHz and you source the timer from SMCLK without any divider and want to have 900Hz as PWM base frequency, simply calculate: 1,000,000Hz / 900Hz = 1111 So your CCR0 value is 1111 (or 1110 because the timer requires one clock cycle to jump back to 0 in up mode) and your CCRx value can vary up to this value for the duty cycle. Dennis
↧