aboutsummaryrefslogtreecommitdiffstats
path: root/delay.c
diff options
context:
space:
mode:
Diffstat (limited to 'delay.c')
-rwxr-xr-x[-rw-r--r--]delay.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/delay.c b/delay.c
index a259fe3..05960e6 100644..100755
--- a/delay.c
+++ b/delay.c
@@ -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++;
}