Question
BELOW IS THE CODE TO EDIT: PART D) Take the Assembly program below and modify it to meet the following conditions: 1) The RGB LED
BELOW IS THE CODE TO EDIT:
PART D)
Take the Assembly program below and modify it to meet the following conditions:
1) The RGB LED at D1 should show the color GREEN.
2) The RGB LED at D2 should show the color WHITE.
3) Both LEDs D1 and D2 should blink ON and OFF with a period of 25 msec (12.5
msec being ON and 12.5 msec being OFF)
4) Place a scope probe at the pin of either D1 or D2 with the active color to measure
the period of that signal. The precision should be at 0.2msec.
#include
config OSC = INTIO2
config WDT = OFF
config LVP = OFF
config BOR = OFF
Color_PORTC equ 0x?? ;
Color_PORTD equ 0x?? ;
Color_Off equ 0x?? ;
OUTER_VALUE equ 0x?? ;
INNER_VALUE equ 0x?? ;
ORG 0x0000
; CODE STARTS FROM THE NEXT LINE
START:
MOVLW 0x00 ; Load W with 0x00
MOVWF TRISC ; Make PORT C bits 0-7 as outputs
MOVWF TRISD ; Make PORT D bits 0-7 as outputs
MAIN_LOOP:
MOVLW Color_PORTC ; Load W with the desired color for PORTC
MOVWF 0x22 ; save desired color into register 0x22
MOVLW Color_PORTD ; Load W with the desired color for PORTD
MOVWF 0x23 ; save desired color into register 0x23
MOVLW OUTER_VALUE ; Load OUTER_VALUE into W
MOVWF 0x24 ; save it o register 0x24
MOVLW INNER_VALUE ; Load INNER_VALUE into W
MOVWF 0x25 ; save it to register 0x25
COLOR_LOOP:
MOVFF 0x22,PORTC ; Get saved color of PORTC and output to that Port
MOVFF 0x23,PORTD ; Get saved color of PORTD and output to that Port
MOVFF 0x24,0x21 ; Copy saved outer loop cnt from 0x24 to 0x21
; NESTED DELAY LOOP TO HAVE THE FIRST HALF OF WAVEFORM
LOOP_OUTER_1:
NOP ; Do nothing
MOVFF 0x25,0x20 ; Load saved inner loop cnt from 0x25 to 0x20
LOOP_INNER_1:
NOP ; Do nothing
DECF 0x20,F ; Decrement memory location 0x20
BNZ LOOP_INNER_1 ; If value not zero, go back to LOOP_INNER_1
DECF 0x21,F ; Decrement memory location 0x21
BNZ LOOP_OUTER_1 ; If value not zero, go back to LOOP_OUTER_1
MOVLW Color_Off ; Load W with the second desired color
MOVWF PORTC ; Output to PORT C to turn off the RGB LED D1
MOVWF PORTD ; Output to PORT D to turn off the RGB LED D2
MOVFF 0x24,0x21 ; Copy saved outer loop cnt from 0x24 to 0x21
; NESTED DELAY LOOP TO HAVE THE FIRST HALF OF WAVEFORM BEING LOW
LOOP_OUTER_2:
NOP ; Do nothing
MOVFF 0x25,0x20 ; Load saved inner loop cnt from 0x25 to 0x20
LOOP_INNER_2:
NOP ; Do nothing
DECF 0x20,F ; Decrement memory location 0x20
BNZ LOOP_INNER_2 ; If value not zero, go back to LOOP_INNER_2
DECF 0x21,F ; Decrement memory location 0x21
BNZ LOOP_OUTER_2 ; If value not zero, go back to LOOP_OUTER_2
; START ALL OVER AGAIN
GOTO MAIN_LOOP ; Go back to main loop
END
PART E) Take the Assembly program in part D and modify it to meet the following conditions 1) Use the two switches connected to PORT B bis and 0 as inputs 2) Based on those two inputs, make the LED DI blink ON and OFF with the color and frequency as indicated on the table below. The LED D2 will always blink with the WHITE color 3) Place a scope probe at any pin of D2 to measure the period of that signal. The precision should be at 0.2 msec. Since D2 is always WHITE, any pin of D2 should reflect the blinking period of the LED DI PORT B Bit Bit0 RGB LED D1 at PORT D bits 0-2 Action RED color blinking every 25 msec GREEN color blinking every 50 msec BLUE color blinking every 100 msec WHITE color blinking every 200 msec Hint 1) Make sure to start the program by setting the TRISB, TRISC and TRISD registers for proper direction of the input and output pins. Also, don't forget to program the ADCONI register 2) Use the .BTFSC, instruction to test the logic state of the input bit you want to check. 3) Add codes between the labels MAIN_LOOP and 'COLOR LOOP to determine what color to output and how long to generate the timing for that color. Use the instruction BTFSC" used in PART C) to test the bits of PORTB to determine the color to display PART E) Take the Assembly program in part D and modify it to meet the following conditions 1) Use the two switches connected to PORT B bis and 0 as inputs 2) Based on those two inputs, make the LED DI blink ON and OFF with the color and frequency as indicated on the table below. The LED D2 will always blink with the WHITE color 3) Place a scope probe at any pin of D2 to measure the period of that signal. The precision should be at 0.2 msec. Since D2 is always WHITE, any pin of D2 should reflect the blinking period of the LED DI PORT B Bit Bit0 RGB LED D1 at PORT D bits 0-2 Action RED color blinking every 25 msec GREEN color blinking every 50 msec BLUE color blinking every 100 msec WHITE color blinking every 200 msec Hint 1) Make sure to start the program by setting the TRISB, TRISC and TRISD registers for proper direction of the input and output pins. Also, don't forget to program the ADCONI register 2) Use the .BTFSC, instruction to test the logic state of the input bit you want to check. 3) Add codes between the labels MAIN_LOOP and 'COLOR LOOP to determine what color to output and how long to generate the timing for that color. Use the instruction BTFSC" used in PART C) to test the bits of PORTB to determine the color to displayStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started