Could someone please help me with this....I need to modify the program below so
ID: 3795837 • Letter: C
Question
Could someone please help me with this....I need to modify the program below so it uses the shift operator to specify red,green, blue bit locations.
The red, green and blue light is produced by a single LED. The port 2 pins 0, 1 and 2 are connected to this single LED. Modify the program so that all rainbow colors are displayed in the rainbow order culminating in WHITE light and then repeating again. (Red, Orange, Yellow, Green, Blue, Indigo, Violet)
This program modification should start the LED sequence with the red LED connected to port 1 and then moving over to the rainbow colors. (This must work on a MSP432P401R launchpad, and be wriiten in assembly language. This CANNOT be written in C or C++)
Here is my original program:
.thumb
.global main
.text
WDTCTRL .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, WDTCTRL ; stop watchdog timer
MOV R0, #0x5A80
STRH R0, [R1] ; store half-word
LDR R1, P2DIR ; port 2 bit 0 is output
LDRB R0, [R1]
ORR R0, #0x07
STRB R0, [R1]
TOGGLE
LDR R1, P2OUT
LDRB R0, [R1]
;EOR R0, #0xFF
MOVW R0, #0x01
STRB R0, [R1]
MOVW R2, #0xFFFF ; lower word
MOVT R2, #0x000F ; top byte
DELAY1
SUBS R2, #0x1
BNE DELAY1
;B TOGGLE
LDR R1, P2OUT
LDRB R0, [R1]
;EOR R0, #0xFF
MOVW R0, #0x02
STRB R0, [R1]
MOVW R2, #0xFFFF ; lower word
MOVT R2, #0x000F ; top byte
DELAY2
SUBS R2, #0x1
BNE DELAY2
LDR R1, P2OUT
LDRB R0, [R1]
;EOR R0, #0xFF
MOVW R0, #0x04
STRB R0, [R1]
MOVW R2, #0xFFFF ; lower word
MOVT R2, #0x000F ; top byte
DELAY3
SUBS R2, #0x1
BNE DELAY3
B TOGGLE
End B End
Explanation / Answer
A)
int indigo;
int red;
int green;
int blue;
int yellow;
int violet;
int wait = 8
int hold = 0int DEBUG = 1;
int loopCount = 40;
int repeat = 3
int j = 0;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(grnPin, OUTPUT);
pinMode(bluPin, OUTPUT);
if (DEBUG) {
Serial.begin(9600);
}
}
void setup()
{
pinMode(redPin, OUTPUT;
pinMode(grnPin, OUTPUT);
pinMode(bluPin, OUTPUT);
if (DEBUG) {
Serial.begin;
}
}
void loop()
{
crossFade(red);
crossFade(green);
crossFade(blue);
crossFade(yellow);
if (repeat) {
j += 1;
if (j >= repeat) {
exit(j);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.