Skip to content

Instantly share code, notes, and snippets.

@shirriff
Last active September 19, 2016 22:18
Show Gist options
  • Save shirriff/92b9b71159dc2e3835dedf2368f0071b to your computer and use it in GitHub Desktop.
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.
/*
* 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