With an AVR Mega32, when using a timer such as Timer2 (8-bit), you do not want to toggle the output pin as this will only give you a 50% duty cycle and you will only be able to control the frequency of that 50% cycle.
This is because the pin is cleared on reaching TOP. So you want to set the pin on match and let it automatically clear on top.
So for Timer2 on the Mega 32 you want to set the TCCR2 register to something like this
TCCR2 = 0b01111011; //0x7B
This is because the pin is cleared on reaching TOP. So you want to set the pin on match and let it automatically clear on top.
So for Timer2 on the Mega 32 you want to set the TCCR2 register to something like this
TCCR2 = 0b01111011; //0x7B
Comments