/******************************************************************************* INT_Slot.c: Single-channels as rising or falling edge interrupt in multi-slots. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) MSC 6.0, MSVC 1.52. Compile mode: large Project: INT_Slot.c ..\Lib\(8000E.Lib,8000.Lib) [24 Mar,2005] by Bill ********************************************************************************/ #include "..\..\..\..\Lib\8000E.h" #include "..\..\..\..\lib\8048.h" void interrupt far ISR_Function_Slot0(void); void interrupt far ISR_Function_Slot1(void); void main(void) { InitLib(); i8048_Init(0); //slot = 0 i8048_Init(1); //slot = 1 //slot = 0 //Enable channel 0 as rising edge interrupt. i8048_Set_RisingReg(0,0,1); //slot 0 ,channel 0 , 1=Enable //slot = 1 //Enable channel 0,1 as rising edge interrupt. i8048_Set_RisingReg(1,0,1); //slot 1 , channel 0 , 1=Enable /****************************************** Slot0's priority is 6. Slot1's priority is 7. Set priority Priority (0~8) 0(High) ~ 7(Low) 8(disable) ******************************************/ i8048_InstallISR(0,(unsigned long *)&ISR_Function_Slot0,6);//Slot:0 i8048_InstallISR(1,(unsigned long *)&ISR_Function_Slot1,7);//Slot:1 for(;;) { //s: Slot c:Channel Print("Rising S0C0==%lu\n\r",i8048_RisingEventCount[0][0]); Print("Rising S1C0==%lu\n\r",i8048_RisingEventCount[1][0]); } } /******************************************************************* Allow the other interrupt to execute. Please don's use the Print or printCom1 function in ISR, these function will cause the problem. ********************************************************************/ void interrupt far ISR_Function_Slot0(void) { if(i8048_Read_RisingEvent(0,0)) { //Add user's ISR code for channel0. } i8048_UnFreezeCPU(0); i8048_UnFreezeINT(0); //Clear interrupt status of 8048. } void interrupt far ISR_Function_Slot1(void) { if(i8048_Read_RisingEvent(1,0)) { //Add user's ISR code for channel0. } i8048_UnFreezeCPU(1); i8048_UnFreezeINT(1); //Clear interrupt status of 8048. }