Chapter 7: Microcontroller Interrupts and Timers
ctc[j++] =
}
else
return 0;
}
}
ctc[j] = '\0';
if(j>4)// must be < 256
{
sendString("Error - Parse_ctc number too large");
return 0;
}
else
{
set_ctc(atoi(ctc));
}
1;
oid set_ctc(int count)
{
char ctc[11];
sendString("Setting the Compare Timer Count to: ");
itoa(count,ctc,10);
sendString(ctc);
sendChar('\r');
MilliSec_init(count);
}
/*
The USART init set the system oscillator to 2 mHz. We set the Timer0
ompare of 250 throws an interrupt every millisecond.
s[i++];
{
sendString("Error - Parse_ctc received a non integer: ");
sendChar(s[i]);
sendChar('\r');
return
}
v
prescaler to clk/8 which gives a 250 kHz input to the timer/counter. A
c
*/
void MilliSec_init(unsigned char count)
{
// Initialize Timer0.
// Enable timer0 compare interrupt
TIMSK0 = (1<<OCIE0A);