First we will explore the timer and the TCNT register. Then we will write some simple programs using the timer overflow interrupt and the real time interrupt. For the pre-lab you should have these programs written, and make sure they compile.
#include <hc12.h>
#define TRUE 1
main()
{
DDRA = 0xff; /* Make all bits of Port A output */
DDRB = 0xff; /* Make all bits of Port B output */
while (TRUE) { }
}
Add a Timer Overflow Interrupt service routine to increment Port A. Set the timer to overflow every 16 ms. Answer the following questions:
You will need to add vector.c to your cc.bat so it will be compiled to a vector.o object file. The first line of cc.bat should look like:
cx6812 -vl -ax +debug crts.s %1.c vector.c
Here is an example lab07.lkf file for linking in the
vector.o file at the right address
# link command file for test program
#
+seg .text -b 0x0800 -n .text # program start address
+seg .const -a .text # constants follow code
+seg .data -b 0x0900 # data start address
crts.o # startup routine
lab07.o # application program
+seg .const -b 0x0b10 # vectors start address
vector.o # interrupt vectors
+def __stack=0x0a00 # stack pointer initial value