Skip to content

Instantly share code, notes, and snippets.

@bradfordbarr
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradfordbarr/88cfca8392e8957340da to your computer and use it in GitHub Desktop.
Save bradfordbarr/88cfca8392e8957340da to your computer and use it in GitHub Desktop.
Assembly code for flashing the Stellaris Launchpad LED
.text
.word 0x2000000 // Initial stack pointer
.word start + 1 // Address of the reset vector '+ 1' denotes THUMB instructions vs ARM instructions.
start:
mov r0, #0x00 // Loads 0x00 into register r0
mov r1, #0xFF // Loads 0xFF into register r1
//RCGCGPIO -> Turns the clock on for each of the GPIO ports
ldr r2, =0x400FE608 // Load the register address into r2
str r1, [r2] // Copy 0xFF into the address contained in r2
//GPIODEN -> Enables all digital input/output on the ARM
ldr r2, =0x4002551C
str r1, [r2]
//GPIODIR -> Sets the data direction register to all Port F output
ldr r2, =0x40025400
str r1, [r2]
//GPIOAFSEL -> Makes sure that digital is being used as opposed to other peripheral
ldr r2, =0x40025420
str r0, [r2]
// Default all pins have 2ma source, but that can be configured (4, or 8ma).
// Pullup not needed because of output pin (always being actively driven, doesn't need to be tied to something).
//GPIODATA
// Bits [9:2] in this address are actually working as a bitmask to see
// what actually gets updated. The mask (0xFF << 2) + 0x4002.5000 == 0x400253FC
// which is why the address is 0x400253FC not 0x40025000. I don't get
// why the implementation is like that, but whatever.
ldr r2, =0x400253FC
loop:
str r1, [r2] // Set the pins on Port F to high
str r0, [r2] // Set the pins on Port F to low
b loop // GOTO loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment