16F18877:
InterruptLED never lights up when I press PushSwitch, and the HeartbeatLED seems to hang for 2-3 seconds when I press.Code:#CONFIG __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF __config _CONFIG5, _CP_OFF & _CPD_OFF #ENDCONFIG DEFINE OSC 32 include "DT_INTS-14.bas" include "ReEnterPBP.bas" ASM INT_LIST macro ;IntSource, Label, Type, ResetFlag? INT_Handler IOC_INT, _IOCinterrupts, PBP, yes endm INT_CREATE ;Creates the interrupt processor ENDASM INTCON = %10000000 ' bit 7 GIE Global Interrupt Enable bit ' 1 = Enables all active interrupts ' bit 6 PEIE Peripheral Interrupt Enable bit ' bit 5-1 Unimplemented: Read as ‘0’ ' bit 0 INTEDG Interrupt Edge Select bit PIE0 = %00010000 ' PERIPHERAL INTERRUPT ENABLE REGISTER 0 ' bit 7-6 Unimplemented: Read as ‘0’ ' bit 5 TMR0IE: TMR0 Overflow Interrupt Enable bit ' bit 4 IOCIE: Interrupt-on-Change Interrupt Enable bit ' 1 = Enables the IOC change interrupt ' bit 3-1 Unimplemented: Read as ‘0’ ' bit 0 INTE: INT External Interrupt Flag bit IOCCP = %00010000 ' INTERRUPT-ON-CHANGE PORTC POSITIVE EDGE REGISTER ' bit 7-0 IOCCP<7:0> Interrupt-on-Change PORTC Positive Edge Enable bits ' 1 = Interrupt-on-Change enabled on the pin ' for a positive-going edge. IOCCFx bit ' and IOCIF flag will be set upon detecting an edge. IOCCN = %00000000 ' INTERRUPT-ON-CHANGE PORTC NEGATIVE EDGE REGISTER ' bit 7-0 IOCCP<7:0> Interrupt-on-Change PORTC Negative Edge Enable bits ' 1 = Interrupt-on-Change enabled on the pin ' for a Negative-going edge. IOCCFx bit ' and IOCIF flag will be set upon detecting an edge. ANSELA = %00000000 ANSELB = %00000000 ANSELC = %00000000 ANSELD = %00000000 ANSELE = %00000000 TRISA = %00000000 TRISB = %00000000 TRISC = %00010000 TRISD = %00000000 TRISE = %00000000 PushSwitch VAR PortC.4 InterruptLED VAR LatC.2 HeartbeatLED VAR LatC.3 ButtonWasPressed VAR byte Pause 500 ' Let PIC and LCD stabilize InterruptLED = 0 ButtonWasPressed = 0 IOCCF.4 = 0 @ INT_ENABLE IOC_INT goto Mainloop IOCinterrupts: if IOCCF.4 = 1 then ButtonWasPressed = 1 ' set a flag IOCCF.4 = 0 endif @ INT_RETURN Mainloop: if ButtonWasPressed = 1 then ' Check flag InterruptLED = 1 endif HeartbeatLED = 1 pause 500 HeartbeatLED = 0 pause 500 goto mainloop end
![]()




Bookmarks