Getting Started

(lily) #1

Chapter 7: Microcontroller Interrupts and Timers


// Sets the compare value

mer Compare (CTC) mode, CLK/8 prescaler
<WGM00)|(1<<CS01);

ARE0)

erfly (remembering to browse to the correct

100

u rec

viding a 500
z puls 3.90625 Hz. pulse on LED7.

set_OCR0A(count);


// Set Clear on Ti
TCCR0A = (1<<WGM01)|(0<


}


void set_OCR0A(unsigned char count)
{
// Sets the compare value
OCR0A = count;
}


// Interrupt occurs once per millisecond
SIGNAL(SIG_OUTPUT_COMP
{
PORTD = milliseconds++;
}


Compile it and download to the Butt
directory).


Using Precision Blinking:


In HyperTerminal you will see:
PC_Comm.c ready to communicate.
You are talking to the Precision Blinking demo.


Type in:
ctc


Yo eive:
Setting the Compare Timer Count to: 100


Note that a ctc value of 250 resets the interrupt to 1 millisecond pro
H e on LED0 and a

Free download pdf