X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=tests%2Fatmega88_timer16.c;h=31e5327a7a8432eeed86bb936811b82fb6f3431a;hb=fb5a31d1e731a1d3f1993063496277c979ce356e;hp=33196254c6aeebe5d1d8fbe670355ba4e107c558;hpb=eca93983ee257cf56d2552444e66723252e35464;p=simavr diff --git a/tests/atmega88_timer16.c b/tests/atmega88_timer16.c index 3319625..31e5327 100644 --- a/tests/atmega88_timer16.c +++ b/tests/atmega88_timer16.c @@ -25,9 +25,9 @@ #include /* - * This demonstrate how to use the avr_mcu_section.h file + * This demonstrates how to use the avr_mcu_section.h file. * The macro adds a section to the ELF file with useful - * information for the simulator + * information for the simulator. */ #include "avr_mcu_section.h" AVR_MCU(F_CPU, "atmega88"); @@ -69,7 +69,7 @@ int main() // timer prescaler to 64 TCCR1B |= (0< 10000) { - TCNT1 = 500; // reset it arbitrarily - PORTB ^= 2; // mark it in the waveform file - } + while (count++ < 100) { + // we read TCNT1, which should contain some sort of incrementing value + tcnt = TCNT1; // read it + if (tcnt > 10000) { + TCNT1 = 500; // reset it arbitrarily + PORTB ^= 2; // mark it in the waveform file + } sleep_cpu(); // this will sleep until a new timer2 tick interrupt occurs } // sleeping with interrupt off is interpreted by simavr as "exit please"