Hi all,
I am playing with an ATMEGA8 and have sucessfuly used the Overflow and CTC mode of timer0 and timer1. I am now trying the fast PWM mode of timer1 and don't get it to work. I have read the datasheet, googled,... but simply can't find the error. I have an oscilloscope connected to PIN15 of the ATMEGA8 and am looking for a squarewave with duty cycle 50% but the PIn stays simply low. Here is my code:
int main (void)
{
DDRB = _BV (PB1); /* PB1 (OC1) is digital output */
DDRB = 0xff;
timer1SetPrescaler( TIMER_CLK_DIV8 );
TCNT1 = 0;
OCR1A = 0x8000;
sbi(TCCR1A,COM1A1); // set OC1 on at COMP
sbi(TCCR1A,COM1A0); // reset OC1 at TOP
sbi(TCCR1A,WGM10); // -
sbi(TCCR1A,WGM11); // - Fast PWM
sbi(TCCR1B,WGM12); // - Fast PWM
sbi(TCCR1B,WGM13); // -
sbi(TIMSK, OCIE1A);
sei();
while (1) /* loop forever */
{
}
return (0);
}
The timer1SetPrescaler funtion simply sets the CS__ bits to some value != 0. The sbi macro is defined as follows:
#define sbi(REG,BIT) REG|=(1 << BIT)
What am I missing?
Thanks a lot!!