Last active
September 19, 2016 22:18
-
-
Save shirriff/92b9b71159dc2e3835dedf2368f0071b to your computer and use it in GitHub Desktop.
C code to blink an LED on the BeagleBone, using the PRU microcontroller.
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
/* | |
* blink demo: blink LED ten times | |
* LED should be connected to P8_11 (pr1_pru0_pru_r30_15) | |
* | |
*/ | |
volatile register unsigned int __R31, __R30; | |
int main(void) { | |
unsigned int loops, delay; | |
for (loops = 0; loops < 10; loops++) { | |
__R30 = __R30 | (1 << 15); // Turn on the LED | |
for (delay = 0; delay < 20000000; delay++) { // loop delay | |
} | |
__R30 = __R30 & ~(1 << 15); // Turn off the LED | |
__delay_cycles(60000000); // Intrinsic method delay | |
} | |
// Send interrupt to host and halt | |
__R31 = 32 | 3; | |
__halt(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment