Hi ya all. I'm new to this forum and microcontrollers in general. So, the problem is that I want to make my AT90CAN128 generate a PWM wave from OCR1A and OCR1B outputs (they are contained in port B). From what I've read, in the atmel's manual, the counter will reload itself automatically. I just have to configure it correctly. So can anybody tell me why doesn't this piece of code work the way I want?:
int main (void) { //starting value of the counter TCNT1 = 0; //turning on the outputs DDRB = 0xff; //counter configuration TCCR1A = 0xa3; //10100011 TCCR1B = 0x14; //00010100 TCCR1C = 0; //top value of the counter OCR1A = 255; OCR1B = 255; //setting the timer interrupt mask TIMSK1 = 0x6; //setting the global interrupt enable flag sei(); while (1); };
What I want to do is to set counter 1 to work in phase correct PWM mode. It's supposed to control the speed of a DC motor via a suitable driver. The only thing I get is the counter counting up and resetting itself just like in fast PWM mode. I know it has to be something really small. Thanks in advance for any help.