Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to change this code to blink red, green and blue LED\'s. THe code must be

ID: 3793255 • Letter: I

Question

I need to change this code to blink red, green and blue LED's. THe code must be written in assembly language. The code must work on a MSP432P401R launchpad. I have included my original code below, but it must be modified to blink red, green and blue. If anyone could help, I would greatly appreciate it.

.thumb
.global main
.text

WDCTRL .field 0x4000480C,32   ;watchdog timer control register
P1DIR .field 0x40004C04,32   ;Port 4 Output
P1OUT .field 0x40004c02,32   ;Port 4 Direction

P2DIR .field 0x40004C05,32
P2OUT .field 0x40004C03,32

main       LDR   R1,WDCTRL   ;stop watchdog timer
MOV   R0, #0x5A80
STRH   R0, [R1]   ;store half-word
      
LDR   R1,P1DIR   ;port 1 bit 0 is output
LDRB   R0, [R1]
ORR   R0, #0x01
STRB   R0, [R1]
TOGGLE
LDR   R1, P1OUT
LDRB   R0, [R1]
EQR   R0, #0xFF
STRB   R0, [R1]

MOV   R2, #0xFFFF
DELAY
SUBS   R2, #0x1
BNE   DELAY
B   TOGGLE

End       B   End

Explanation / Answer

.thumb
.global main
.text

WDCTRL .field 0x4000480C,32   ;watchdog timer control register
P1DIR .field 0x40004C04,32   ;Port 4 Output
P1OUT .field 0x40004c02,32   ;Port 4 Direction

P2DIR .field 0x40004C05,32
P2OUT .field 0x40004C03,32

main       LDR   R1,WDCTRL   ;stop watchdog timer
MOV   R0, #0x5A80
STRH   R0, [R1]   ;store half-word
      
LDR   R1,P1DIR   ;port 1 bit 0 is output
LDRB   R0, [R1]
ORR   R0, #0x01
STRB   R0, [R1]
TOGGLE
LDR   R1, P1OUT
LDRB   R0, [R1]
EQR   R0, #0xFF
STRB   R0, [R1]

MOV   R2, #0xFFFF
DELAY
SUBS   R2, #0x1
BNE   DELAY
B   TOGGLE

End       B   End

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote