Created
April 20, 2018 07:51
-
-
Save AndrioCelos/dfd3a29b5451b368cbc07c2f4b86f883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void delay(unsigned int delayms) { | |
// Enable interrupts. | |
EI(); | |
// Enable the timer 0 interrupt. | |
IRQ0ENH |= 0x20; | |
// Set the timer. | |
T0CTL1 = TCTL1(0, 0, 7, TMODE_ONE_SHOT); | |
T0CTL0 = TCTL0(0); | |
T0 = 1; | |
T0R = 145; | |
for (; delayms > 0; --delayms) { | |
T0CTL1 |= 0x80; | |
// HALT mode stops the CPU, reducing power use. | |
// Several events can resume the CPU, including interrupts. | |
asm("HALT"); | |
} | |
} | |
interrupt void isr_timer0() _At TIMER0 { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment