Experiment #9

advertisement
Experiment 9:
Real Time Interrupt
ECE 425 Lab
Pei-chun Chen
Ari Mahpour
Abstract:
This lab is an exercise in real time interrupts, which helps student to understand the delay time in
interrupt that can wait the time to show the LED run in each time. Also, let student to understand that how
the software to control the time in running the LED light in the specific times.
Procedure:
Materials:
1.
2.
3.
4.
5.
6.
7.
Computer and winide software
68HC12 development board
RS232 cable
Power cable
Power supply
LED
330Ω, resister
Require:
1. Connect port J (PJ0 to PJ7) on your EVB to eight LEDs, each with a current limiting
resistor, which use the 330 Ω
2. Write programs using RTI interrupt systems such that every 5 seconds, one and only one
LED will be turned ON. For example, firstly, the LED connecting to PJ0 in ON, and all
others are OFF. 5 seconds later, the LED connecting to PJ1 is ON, and all others are
OFF. After that, the LEDs connecting to PJ2, PJ3, PJ4, PJ5, PJ6, and PJ7 will ON once at
a time (every 5 seconds); this is followed by all eight LESs OFF; and then repeat again
and again. Note that when the output of Port J is 1, the connected LED will be ON;
otherwise, it’s OFF.
3. You need to use the RTI system. The MCLK is operating at 8 MHz. set the RTR[2:0]
buts to ”111” (so you can calculate the number of RTI interrupt events needed for 5
second delay). Set all eight pins of port J for outputs. Write your ISR to set up outputs of
port J (e.g., every 5 seconds, output a number to port J). Please refer to the examples we
discussed in class and the program we used in previous experiment for the setup of I/O
ports.
Calculate the five second delay:
Results:
In this experiment, all data depend on the code to run the LEDs run each bit.
All the code from this experiment is show below, which we use.
* Set up compiler directives
PORTJ
EQU
DDRJ
EQU
DDRJ_INI
EQU
REGBASE
EQU
RTICTL
EQU
RTIFLG
EQU
FIVE
EQU
RTIF
EQU
$0028
$0029
$FF
$0000
$0014
$0015
!77
$80
* Create values in memory
ORG
RTICNTR
RMB
LEDBLINK
FCB
$800
$2
; RTI interrupt count
%00000001 ; starting LED light
; PortJ setup
; Base address of A4 EVB register block
; RTI control
; RTI flag
; 5 second event delay
; Mask for RTIF flag
* EVB ISR
ORG
LDD
PSHD
LDD
LDX
JSR
PULX
$5000
#$4000
LDAA
STAA
SEI
LDS
LDX
LDD
STD
BSET
LDAA
STAA
CLI
#DDRJ_INI
DDRJ
; Disable interrupts
#$8000
; Initialize stack
#REGBASE
; Use index addressing
#FIVE
; Set RTI interrupt count
RTICNTR
RTICTL,X,$87 ; Set RTI prescale ("111") and enable RTI
#RTIF
; Load flag mask
RTIFLG,X
; Clear the RTI flag
; Clearing the I bit - Enable the interrupt
BRA
INFINITE
#!24
$FE1A
0,X
; Address of ISR
; RTI D-BUG12 Interrupt Offset
; Set User Vector Routine
* Main program
INFINITE:
; Waiting for the RTI
*Interrupt
RTIservc
ORG
LDX
LDAA
STAA
LDX
DEX
BNE
LDX
LDAA
STAA
LDAA
ROLA
STAA
NOT_YET:
LEDBLINK
; Blink LED
PORTJ
LEDBLINK
; Move to next LED
; Traverse
LEDBLINK
; Emmit
STX
RTI
$4000
#REGBASE
; Using index addressing
#RTIF
; Load RTI flag mask
RTIFLG,X
; Reset flag
RTICNTR
; Load RTI counter
; Decrement counter
NOT_YET
; Branch if !0
#FIVE
; If 0 --> reload counter
RTICNTR
; Store result of the RTI counter
; Return from the ISR
Flow chart:
Initialize program
-disable SEI
-initialize stack pointer
-set RTI pre-scale factor RTT[2:0] and enable RTI with
RTE bit in the RTICTL register
Clear RTIF flag in
RTIFLG register
-initialize RTI interrupt counter
-enable maskable interrupts (CLI)
-clear RTIF flag in RTIFLG register
Decrement interrupt
counter
NO
Inter 0?
YES
RTIZ
ZIiI
LED display to J
Hardware:
no
Comment: in the above of the hardware result, we could see that the LED is ON in the third. By this
experiment, we need to show in every 5 second to ON one LED. In order to show this LED, we want to
make sure that this software is work well, so we test it and to get the good result that the LED is really
work and could ON in the next one, therefore, we could see that this software is work and ON in every 5
second at above picture.
Conclusion:
In this experiment, we try to use the code from the book, which seems that has some codes are
wrong. In order to fix the wrong part, we get to understand that the main program doesn’t need two
main addresses which might confuse us and might not help to work well in this experiment. However,
we still spent more time to fix the problem which we could not figure out, even the program looks find.
Finally, we got the problem to fix which is the value we need to sent data to be the immediately to
treated as the actual data, which should use # symbol. Therefore, in this experiment, we learn that we
should be careful to use the symbol.
Download