Hi :)
I am trying to learn about using the timers in C.
Is this code all I need to use timer0 in compare mode?
I'd load it into an AVR and test it but I'm waiting on a
replacement butterfly as I smoked my original...this
seems to compile OK though...but I can't simulate it
as it freezes in the SIGNAL(SIG_OUTPUT_COMPARE1)
function.
// timer2.c
//for atmega169
#include
unsigned char tickcount = 0;
void main(void)
{
DDRD = 0xFF; //portd all outputs
TIMSK0 = (1<<OCIE0A);
OCR0A = 250; //compare value
// Setup for (CTC) mode, CLK/8 prescale
TCCR0A = (1<<WGM01)|(0<<WGM00)|(1<<CS01);
}
SIGNAL(SIG_OUTPUT_COMPARE0)
{
PORTD = tickcount++;
}
And how would I change this code to use the 16bit timer1 ???
It is more complicated because it has low and high bytes...