diff options
Diffstat (limited to 'delay.c')
-rwxr-xr-x[-rw-r--r--] | delay.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -20,18 +20,23 @@ #include "board.h" -static unsigned int delayTicks = 0; +volatile unsigned int delayTicks = 0; void delayInit(void) { TACCTL0 |= CCIE; - TACCR0 = 1000; - TACTL |= TASSEL_1 | MC_1; + TACCR0 = 128; + TACTL |= TASSEL_2 | MC_1 | ID_3; +} + +void delay(unsigned int ms) +{ + unsigned int target = delayTicks + ms; + while (delayTicks < target); } __attribute__((__interrupt__(TIMER0_A0_VECTOR))) static void delayInterruptHandler(void) { - P1OUT ^= LED; - delayTicks++; + delayTicks++; } |