$30
Assignment
1. Write an assembly program that interfaces switches, SW1 and SW2, and LEDs, LED1 and
LED2, as follows (You should use interrupts for both switches).
a. Initially, both the LEDs should be turned off.
b. When SW2 is pressed for the first time, LED2 should be turned on. The next time SW2 is pressed, LED2 is turned off, and so on. Hence each press changes the state of LED2.
c. When SW1 is pressed, LED1 blinks 3 times at 1Hz and then toggles the state of LED2.
d. What happens when SW2 is pressed while LED1 is blinking? Does that disrupt the blinking? Does SW2 function correctly? Explain.
*Be mindful of the Notes below*
2. Write a C program that interfaces switches SW1 and SW2, LEDs 1 and 2, and the clock frequency as follows (You should use interrupts for both switches): [50 pts]
a. Initially, LED1 is on and LED2 is off and the clock frequency is set to 1MHz.
b. Both LEDs blink with a 50,000 loop iteration delay.
c. Every time SW1 is pressed, the blinking frequency is increased by doubling the clock frequency and the clock frequency does not exceed 8MHz.
d. Every time SW2 is pressed, the blinking frequency is decreased by halving the clock frequency and the clock frequency does not go below 1MHz.
e. Calculate the LEDs blinking rate for each clock frequency and show your work.
Hint: The clock frequency should be either 1MHz, 2MHz, 4MHz, or 8MHz. You could use global variables to determine what the next value should be.
*Be mindful of the Notes below*
3. Bonus (up to 10pts): Rewrite the first question in C and extend it in the following manner:
a. While SW1 and SW2 are pressed together, both LEDs should be on and they should turn off when the switches are released.