Since the Final Project requires that the User Button generate interrupts, the p
ID: 664550 • Letter: S
Question
Since the Final Project requires that the User Button generate interrupts, the purpose of this assignment is to practice setting up the button to trigger interrupts and to execute an interrupt handler. This will be done by modifying the design of Homework #16 as follows. 1. When the board first resets, perform any required initialization of variables, GPIO ports, etc. 2. Turn OFF all four LEDs and “do nothing” until an interrupt is triggered by the user button, and then go to the next step. 3. Turn on one LED every half-second in a clockwise pattern as follows: Green ON Green-Orange ON Green-Orange-Red ON Green-Orange-Red-Blue ON (PD12-13-14-15) All OFF Repeat this pattern until the next user button interrupt, and then go to the next step. 4. Turn on one LED every second in a counter-clockwise pattern as follows: Blue ON Blue-Red ON Blue-Red-Orange ON Blue-Red-Orange-Green ON (PD15-14-13-12) All OFF Repeat this pattern until the next user button interrupt, and then go back to Step 2. Steps 2-4 are to be repeated continuously. As with previous programs, partition the program into subroutines, with each subroutine performing a specific function (LED_ON, LED_OFF, DELAY, etc.).
Explanation / Answer
so for your old assignment add this handler to have a interrupt......
If you use c# or javascript it was easy handle button enabled interrupt..since they are providing interrupt methods directly.
using interrupt asembler
--------------------------------------------------------------
$mod51
ORG 00H
LJMP Main
;interrupt service routine to interrupt lightining
MOV A, #88H ; 10001000B
LOOP:
MOV P1, A
ACALL DELAY
RR A ; Delaying for interrupt
SJMP LOOP
DELAY:
MOV TMOD, #01H
MOV TCON, #00H
MOV TL1, #0E0H
MOV TH0, #0B1H
SETB TR0
WAIT: JNB TF0, WAIT
RET
END
;Main
ORG 30H
MAIN: MOV IE,#1000 0100 ;external interrupt ebnabling
Here: SJMP HERE
END
--------------------------------------------------
using javascript
function clickInterrupt( event ) {
event.preventDefault();
//do more stuff here.
}
$('buttonInterrupt').on('click', clickInterrupt )