/* **********tut5.c***************** Simulator tutorial program for the MC68HC11EVB Using the interrupting output compare squarewave generation This example accompanies the book "Embedded Microcomputer Systems: Real Time Interfacing", Brooks-Cole, copyright (c) 2000, Jonathan W. Valvano 7/6/99 Interface between the TExaS simulator running a MC68HC11 EVB with ICC11 freeware compiler TExaS Copyright 1999 by Jonathan W. Valvano for more information about ICC11 see http://www.imagecraft.com You may use this file without restrictions */ #include "HC11.h" /* global variables */ unsigned int time; #define OC5 0x08 void main(void){ time=0; TMSK1=OC5; /* arm OC5 */ TCTL1=0x01; /* OC5 toggle on output compare */ TOC5=TCNT+100; /* first interrupt in 100 cycles */ TFLG1=OC5; /* initially clear OC5F */ asm(" cli"); /* enable interrupts */ while(1){} } /* ----------called when TCNT=TOC5--------- */ void OC5hndlr(void){ time++; TOC5=TOC5+1000; /* next interrupt in 1000 cycles */ TFLG1=OC5; /* acknowledge OC5F */ asm(" rti"); } /***warning**** highest level interrupt program should be so simple it doesn't push things on the stack this inconvenience is only for the freeware compiler PS if you need to make it more complex, call a function and perform the complex operations in the function. e.g., see the SCIhandler in the file SCI11a.c */ void resetVectors(void){ /* not really a function, but this must be last */ asm(" org $FFE0"); asm(" FDB _OC5hndlr"); asm(" org $FFFE"); asm(" FDB __start"); asm(" org $FC00"); /* puts rts in a harmless place */ /* string constants also placed here */ /* the value FC00 means you can have up to 1000 characters of strings */ }