Solutions to Exam 2
TMSK2 = TMSK2 | 0x01;
TMSK2 = TMSK2 & ~0x02;
TFLG2 = 0x80;
Below is some data in an HC11 memory:
| 0 1 2 3 4 5 6 7 8 9 A B C D E F -----|--------------------------------------------------------------- 2000 | 10 23 3B 7C 10 04 86 80 B7 10 25 3B FC 10 18 F3 2010 | 12 50 FD 10 18 86 40 B7 10 23 3B FC 10 12 DD 02 2020 | 86 02 B7 10 23 3B 7C 10 03 86 40 B7 10 25 3B 86 -----|--------------------------------------------------------------- FFD0 | 7E E3 4B 7E E5 38 21 54 25 83 20 34 E5 38 20 03 FFE0 | E5 38 2A F2 26 13 20 0C 25 F2 E5 38 20 1B 27 1A FFF0 | 20 26 22 13 25 AA E9 1F E5 38 E5 38 E5 38 E0 00
7C 10 04 INC 0x1004 ; increment Port B (0x1004) 86 80 LDAA #0x80 ; clear TOF flag by writing 1 to B7 10 25 STAA 0x1025 ; Bit 7 of TFLG2 register (0x1025) 3B RTI
#include <hc11.h> #define TRUE 1 unsigned short time; void tic2_isr(void); main() { TMSK2 = TMSK2 | 0x02; /* Set timer for 4~us interval */ TMSK2 = TMSK2 & ~0x01; TCTL2 = TCTL2 | 0x10; /* Capture rising edge of Input Capture 1 */ TCTL2 = TCTL2 & ~0x20; TIC2_JMP = JMP_OP_CODE; /* Set interrupt vector to point to */ TIC2_VEC = tic2_isr; /* service routine */ TMSK1 = TMSK1 | 0x04; /* Enable IC1 interrupt */ TFLG1 = 0x04; /* Clear IC1 flag */ enable(); /* Enable interrupts -- clear I bit of CCR */ while (TRUE) { ; } } #pragma interrupt_handler tic2_isr void tic2_isr(void) { time = TIC2; /* Read time of event */ TFLG1 = 0x04; /* Clear IC1 flage */ }