*****HAVE TO USE ASSEMBLY LANGUAGE (keil Uvision5)****** Step 1 – Blinking LED W
ID: 3910466 • Letter: #
Question
*****HAVE TO USE ASSEMBLY LANGUAGE (keil Uvision5)******
Step 1 – Blinking LED
Write a program that continuously blinks the blue LED ON and OFF with a frequency of 2 seconds – ON for one second and OFF for one second. Implement this with a main program and three subroutines.
• Subroutine 1 (InitLED) - Initialize I/O ports and LED state.
• Subroutine 2 (LEDonoff) – Turn the LED ON or OFF, according to a parameter passed to the subroutine in register R0.
• Subroutine 3 (Delay) – Implement a one-second time delay (i.e. “do nothing” for about one second.) • Main Program – Call the three subroutines to produce the behavior described in the problem statement.
Step 2 – Button-controlled blinking LED
Modify the program from Step 1 so that the LED state is “frozen” at its current state (ON or OFF) if the user button is being held down, and then continues blinking when the button is released. Add two additional subroutines.
• Subroutine 4 (InitButton) – Initialize the I/O port pin connected to the User button.
• Subroutine 5 (CheckButton) – Check the state of the user button and return 1 in register R0 if the button is pressed or 0 if the button is not pressed.
Explanation / Answer
ORG 0000H // reset address and initializing
InitLED MOV PSW, #00
LEDonoff: CPL P1.0 // complementing LED connected to port P1
Delay: DJNZ R0, Delay // delay
MAIN:
CALL InitLED
CALL LEDonoff
MOV R0, #0FFH
CALL Delay
AJMP LEDonoff
END
USING SWITCH-----------
InitButton: MOV P0, #83H
CheckButton: MOV A, P0
MAIN:
CALL InitLED
CALL LEDonoff
CALL InitButton
CALL CheckButton
RRC A
JC NXT
CLR P0.7
SJMP CheckButton
NXT: RRC A
JC CheckButton
SETB P0.7
SJMP CheckButton
MOV R0, #0FFH
CALL Delay
AJMP LEDonoff
END
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.