Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C Programming for microcontrollers (Joe Pardue, 2005).pdf
Скачиваний:
277
Добавлен:
12.08.2013
Размер:
4.55 Mб
Скачать

Chapter 7: Microcontroller Interrupts and Timers

//Sets the compare value set_OCR0A(count);

//Set Clear on Timer Compare (CTC) mode, CLK/8 prescaler TCCR0A = (1<<WGM01)|(0<<WGM00)|(1<<CS01);

}

void set_OCR0A(unsigned char count)

{

// Sets the compare value OCR0A = count;

}

// Interrupt occurs once per millisecond SIGNAL(SIG_OUTPUT_COMPARE0)

{

PORTD = milliseconds++;

}

Compile it and download to the Butterfly (remembering to browse to the correct 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: ctc100

You receive:

Setting the Compare Timer Count to: 100

Note that a ctc value of 250 resets the interrupt to 1 millisecond providing a 500 Hz pulse on LED0 and a 3.90625 Hz. pulse on LED7.

133