/* filename ******** IR.C ************** IR Remote and Interrupt Input Capture program for the MC68HC11 EVB 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 IR remote connected to both PA1, PA0 Increments global variables count+1 falling edge on PA1/IC2 count rising edge on PA0/IC3 */ #include "HC11.h" #define IC2 0x02 #define IC3 0x01 unsigned char count[2]; /* interrupt on PA0/IC3, IR signal rising edge */ void TIC3handler(void){ TFLG1=IC3; /* acknowledge interrupt */ ++count[0]; /* count number of rising edges */ PORTB=count[0]; asm(" rti"); } /* interrupt on PA1/IC2, IR signal falling edge */ void TIC2handler(void){ TFLG1=IC2; /* acknowledge interrupt */ ++count[1]; /* count number of falling edges */ PORTC=count[1]; 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 main(void){ DDRC=0xFF; /* PC7-PC0 outputs */ TMSK1=IC2+IC3; /* arm IC3 IC2 */ count[1]=count[0]=0; /* 00,10,01, falling on PA1/IC2, rising on PA0/IC3 */ TCTL2=0x09; TFLG1=IC2+IC3; /* initially clear IC2F IC3F flags */ asm(" cli"); /* enable interrupts */ while(1){} } void resetVectors(void){ /* not really a function, but this must be last */ asm(" org $FFEA"); asm(" FDB _TIC3handler"); asm(" FDB _TIC2handler"); 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 */ }