Chapter 9 – Digital Meets Analog – ADC and DAC
riangle()
hich gives a 250 kHz input to the timer/counter. A compare of 250 throws
pt every millisecond.
it(unsigned char count)
ize Timer0.
// Enable timer0 compare interrupt
ompare value
set_OCR0A(count);
Clear on Timer Compare (CTC) mode,
= (1<<WGM01)|(0<<WGM00)|(1<<CS02)|(0<<CS01)|(0<<CS00);
id set_OCR0A(unsigned char count)
GNAL(SIG_OUTPUT_COMPARE0)
gm_read_word(pWave + count); // used for test
RTD = pgm_read_word(pWave + count++); // read table
}
void startT
{
startWave(3);
}
/
The USART init set the system oscillator to 2 mHz. We set the Timer0 prescaler
to clk/8 w
an interru
/
void MilliSec_in
{
// Initial
TIMSK0 = (1<<OCIE0A);
// Sets the c
// Set
TCCR0A
}
// Initialize for 1 millisecond interrupt
void DigitalOscilloscopeTimerInit()
{
// Initialize Timer2.
// Enable timer2 compare interrupt
TIMSK2 = (1<<OCIE2A);
// Sets the compare value
OCR2A = 1;
// Set Clear on Timer Compare (CTC) mode,
TCCR2A = (1<<WGM21)|(0<<WGM20)|(1<<CS22)|(0<<CS21)|(0<<CS20);
}
vo
{
// Sets the compare value
OCR0A = count;
}
// Interrupt occurs once per millisecond
SI
{
// signal += p
PO
tenth++;