EE 308 -- LAB 06
Simple Timer Interrupts
Start with the following program, which is just a do-nothing infinite loop:
#include <hc11.h>
#define TRUE 1
main()
{
DDRC = 0xff; /* Make all bits of Port C output */
while (TRUE) { }
}
-
Add a Timer Overflow Interrupt service routine to increment Port B. Test
your program on the simulator. After starting the simulator, and before
loading your program, give the command
SCRIPT E:\EE308\E.SCR
. This will load BUFFALO into the simulator's
memory, and initialize all other memory in the simulator so you don't get an
uninitialized memory error.
Note the following points:
-
How long does it take Port B to overflow on the simulator? The EVBU has a
2 MHz clock. What is the approximate `clock rate' on the simulator?
- Observe the TCNT register in the TIMER window. Does Port B
increment when TCNT rolls over from 0xFFFF to 0x0000?
- Set a break point at the first address in your interrupt service
routine. Run your program again. What value does TCNT have when you
hit your breakpoint? Try this several times. Why does TCNT have this
value?
When you reach the breakpoint in your interrupt service routine, what value
does the I bit of the CCR have? Why? When your program is
running between breaks, what value does the I bit have?
-
Stop your program. Try to reset TCNT to 0x0000. What happens?
-
Set the interrupt bit to 1 ( I = 1 in the command window). Start your
program running again ( GO in the command window -- do not reset your
PC when you type in the GO command). What happens to Port B now?
Why?
-
Set the interrupt bit back to 0. Start your program running again.
What happens to Port B now? Why?
-
What happens when you fail to clear the TOF flag as part of your TOF
interrupt service routine? Check your conjecture by commenting this line
out of your program and running the new program on the simulator.
-
Add a Real Time Interrupt to increment Port C. Set the RTI interrupt
period to 8.19 ms. Observe the operation of this program on the simulator.
About how long will it take this program to overflow Port C on the EVBU?
-
Test your TOI and RTI program on the EVBU. Do the Port B and Port C
overflow times agree with your predictions?
Bill Rison,
<rison@ee.nmt.edu
>
Thr Feb 20 1997
© 1997, New Mexico Tech