Question: Build a program using assembly instructions that turns on both the blue and red LEDs on your Tiva C board. Then, modify your program to

Build a program using assembly instructions that turns on both the blue and red LEDs on your Tiva C board.
Then, modify your program to use switch SW1 on your Tiva C board to control those LEDs by turning on the blue and green led to create aqua blue (SW1 pressed makes the LEDs turn on, SW1 released makes the LEDs turn off).
Here is what I have so far it turns on the red led when the button is pressed. .thumb
.global main
; Your constants go here
main:
.asmfunc
; Initial setup
aSystemControlBase: .field 0x400FE000,32 ; Base address for the System Control registers (which includes RCGCGPIO)
bit5: .equ 0x20 ; bit 5 enables GPIO port F
oRCGCGPIO: .equ 0x608 ; offset for RCGCGPIO from base System Control registers address
aGPIOFBase: .field 0x40025000,32 ; Base address for GPIO Port F registers (APB)
pin2: .equ 0x02 ; bit 2 high only, for setting pin2 direction, etc.
pin4: .equ 0x10 ; bit 4 high only, for setting pin4 pull-up, etc.
oGPIODIR: .equ 0x400 ; offset for GPIODIR (pin direction) from any GPIO port base address
oGPIODEN: .equ 0x51C ; offset for GPIODEN (digital I/O) from any GPIO port base address
oGPIOPUR: .equ 0x510 ; offset for GPIOPUR (pull-up resistor) from any GPIO port base address
swread: .equ 0x040 ; offset for GPIODATA from any GPIO port base address, further offset to mask pin 4 to allow read
oWrite: .equ 0x08 ; offset for GPIODATA from any GPIO port base address, further offset to mask pin 2 to allow write
;red light when button is pushedd (PF2&3)
;light off when button is let go (PF4)
config: LDR R0, aSystemControlBase
MOV R1, #bit5
STR R1,[R0,#oRCGCGPIO]
LDR R0, aGPIOFBase
MOV R1, #pin2
STR R1,[R0,#oGPIODIR]
LDR R0, aGPIOFBase
MOV R1, #0x12
STR R1,[R0,#oGPIODEN]
LDR R0, aGPIOFBase
MOV R1, #pin4
STR R1,[R0,#oGPIOPUR]
impl:
LDR R3,[R0,#swread]
CMP R3, #pin4
BEQ off
on: MOV R4,#0x02
STR R4,[R0,#oWrite]
B impl
off:
MOV R4,#0
STR R4,[R0,#oWrite]
B impl
loop:
B loop
.endasmfunc
.end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!