diff --git a/Makefile.avr b/Makefile.avr index 611776f..a9011df 100644 --- a/Makefile.avr +++ b/Makefile.avr @@ -12,7 +12,7 @@ LDFLAGS += -mmcu=$(MCU) AVDFLAGS += -p $(MCU) AVDFLAGS += -c usbtiny -FUSES += -U lfuse:w:0x7f:m +FUSES += -U lfuse:w:0xff:m FUSES += -U hfuse:w:0xd9:m FUSES += -U efuse:w:0xff:m diff --git a/avr.c b/avr.c index 661d130..e88c250 100644 --- a/avr.c +++ b/avr.c @@ -20,7 +20,7 @@ ISR(TIM0_OVF_vect) m += (256 * 64); if (m >= JIFFY_uS) { - m %= JIFFY_uS; + m -= JIFFY_uS; tick = true; jiffies += 1; } diff --git a/avr.h b/avr.h index 3031cae..12da855 100644 --- a/avr.h +++ b/avr.h @@ -5,7 +5,6 @@ #include #include - // Make sure JIFFY_uS is going to be an integer and not a float! #define JIFFIES_PER_SECOND 100 #define JIFFY_uS (1000000 / JIFFIES_PER_SECOND) diff --git a/main.c b/main.c index 8f867b8..34e73ca 100644 --- a/main.c +++ b/main.c @@ -241,17 +241,16 @@ void loop() { uint32_t i; - if (tick) { tick = false; update_controller(); + if (jiffies % 66 == 0) { + PORTB ^= 0xff; + } if (jiffies % (JIFFIES_PER_SECOND / 10) == 0) { - if (jiffies % JIFFIES_PER_SECOND == 0) { - PORTB ^= 0xff; - } switch (state) { case SETUP: break;