trying to figure out how to get 1s in .1s intervals

This commit is contained in:
Neale Pickett 2013-05-04 20:39:31 -06:00
parent 65cbd98027
commit 27a9eb281a
4 changed files with 5 additions and 7 deletions

View File

@ -12,7 +12,7 @@ LDFLAGS += -mmcu=$(MCU)
AVDFLAGS += -p $(MCU) AVDFLAGS += -p $(MCU)
AVDFLAGS += -c usbtiny AVDFLAGS += -c usbtiny
FUSES += -U lfuse:w:0x7f:m FUSES += -U lfuse:w:0xff:m
FUSES += -U hfuse:w:0xd9:m FUSES += -U hfuse:w:0xd9:m
FUSES += -U efuse:w:0xff:m FUSES += -U efuse:w:0xff:m

2
avr.c
View File

@ -20,7 +20,7 @@ ISR(TIM0_OVF_vect)
m += (256 * 64); m += (256 * 64);
if (m >= JIFFY_uS) { if (m >= JIFFY_uS) {
m %= JIFFY_uS; m -= JIFFY_uS;
tick = true; tick = true;
jiffies += 1; jiffies += 1;
} }

1
avr.h
View File

@ -5,7 +5,6 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
// Make sure JIFFY_uS is going to be an integer and not a float! // Make sure JIFFY_uS is going to be an integer and not a float!
#define JIFFIES_PER_SECOND 100 #define JIFFIES_PER_SECOND 100
#define JIFFY_uS (1000000 / JIFFIES_PER_SECOND) #define JIFFY_uS (1000000 / JIFFIES_PER_SECOND)

7
main.c
View File

@ -241,17 +241,16 @@ void
loop() loop()
{ {
uint32_t i; uint32_t i;
if (tick) { if (tick) {
tick = false; tick = false;
update_controller(); update_controller();
if (jiffies % 66 == 0) {
PORTB ^= 0xff;
}
if (jiffies % (JIFFIES_PER_SECOND / 10) == 0) { if (jiffies % (JIFFIES_PER_SECOND / 10) == 0) {
if (jiffies % JIFFIES_PER_SECOND == 0) {
PORTB ^= 0xff;
}
switch (state) { switch (state) {
case SETUP: case SETUP:
break; break;