/edit
This thread evolved from a questions to answers post...
Last Edited: Sun. Jun 1, 2008 - 06:03 AM
/edit
This thread evolved from a questions to answers post...
Where I am at...
The counting sequence is determined by the setting of the WGM01 and WGM00 bits located in the Timer/Counter Control Register (TCCR0A) and the WGM02 bit located in the Timer/Counter Control Register B (TCCR0B).
#includeint main (void) { //ATMega88 //SET OUTPUT DDRD |= (1 << 6); //Set TCCR0A - Set OC0A on Compare Match Up-Count, //Clear OC0A on Compare Match Down-Count, Phase //Correct PWM Mode TCCR0A |= (1 << COM0A1) | (1 << COM0A0) |(1 << WGM00); //Set Clock Source TCCR0B |= (1 << CS00); //no prescaling while (1) { } }
Per datasheet:
"The PRTIM0 bit in “Minimizing Power Consumption” on page 42 must be written to zero to
enable Timer/Counter0 module."
added enable line, saw a quick flash from PD6 and then nothing...
#includeint main (void) { //ATMega88 //SET OUTPUT DDRD |= (1 << 6); //Set TCCR0A - Set OC0A on Compare Match Up-Count, //Clear OC0A on Compare Match Down-Count, Phase //Correct PWM Mode TCCR0A |= (1 << COM0A1) | (1 << COM0A0) |(1 << WGM00); //Set Clock Source TCCR0B |= (1 << CS00); //no prescaling //Enable Timer/Counter 0 PRR |= (0 << PRTIM0); while (1) { } }
Well I kind of got it. I set the Output Compare Register A to a value between 0 - 255 and it changes the intensity of the LED. Thing is that I thought my settings for TCCR0A automatically set the TOP and BOTTOM to 0xFF and 0x00. Nothing like talking to yourself :? . Hmm...
#includeint main (void) { //-------- //ATMega88 //-------- //Set Output PD6 DDRD |= (1 << 6); //Set TCCR0A TCCR0A |= (1 << COM0A1) | (1 << COM0A0) |(1 << WGM00); //Set Clock Source TCCR0B |= (1 << CS00); //no prescaling //Enable Timer/Counter 0 PRR |= (0 << PRTIM0); //Set Output Compare Register A OCR0A = 255; //Run Forever while (1) { } }