7.4. THE REAL TIME INTERRUPT 83
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INTERRUPT SERVICE
SERVICE
; TOGGLE PA4
LDAA #%00010000
EORA PORTA
STAA PORTA
; TURN OFF THE FLAG!
LDAA #%01000000 <= This is different
STAA TFLG2
; END WITH AN RTI
RTI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Connect the service to the interrupt ;
ORG $00EB ; $00EB0 WHERE THE SERVICE STARTS
JMP SERVICE ; JUMP TO WHERE THE SERVICE CODE ACTUALLY IS
7.4.1 Exercises
1. Modify the above program to generate a 61 Hz square wave by setting the
RTI interrupt rate to 61 Hz.
2. After you made the modification, toggle PA4 every 61 interrupts (Hint, set
up a counter and initialize it to 61 in the main program. In the interrupt
service, decrement the counter. When the counter reaches zero, toggle the
pin and reset the counter back to 61). Verify that the signal you generate
is a 1 Hz square wave
3. Create a simple clock. In addition to toggling the pin, increment an 8-bit
variable called TIME. In the main loop, instead of printing Z’s, print the
variable using OUT1BSP.
Comentarios a estos manuales