Hi Folks,
I was too quick in replying all was good - it isn't. The test I performed was only to see the serial Int! and then left it for more urgent tasks.
When I went back to do more testing I found the LED frozen, although further button pushes still gave the Int! - so the running task never gets returned to.
Am I missing something obvious here or are further mods required?
I've attached the edited Inc file (thank you Richard, tumbleweed and Henrik).
Cheers,
Bill
Code:
'****************************************************************
'* Name : Test_IOCAN.pbp *
'* Author : WJS *
'* Date : 27/08/2023 *
'* Device : 16F18426 *
'* Version : 1.0, PBP 3.1.5.4 *
'* Notes : Test interrupt code for pushbutton on A.2 pulled *
'* : up 10k. *
'****************************************************************
'
' Uses modified DT_INTS-14.bas (v1.10) now renamed DT_INTS-14 v1-2.bas for 16F18426
' - Ints take place but does not appear to return to program.
'
#CONFIG ; 16F18426
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTS_PWRT_64 & _LPBOREN_OFF & _BOREN_SBOREN & _BORV_LO & _ZCDDIS_OFF & _PPS1WAY_OFF & _STVREN_ON
__config _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_SWDTEN & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
__config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTD_OFF & _WRTSAF_OFF & _LVP_OFF
__config _CONFIG5, _CP_OFF
#ENDCONFIG
' -----[ Initialization 16F18426]---------------------------------------------------------------------------------------
DEFINE OSC 32 ' Adjust to suit design.
; PIR0,IOCIF, PIE0,IOCIE ;-- ENHANCED CORE_Int On Change
IOCAF = 0 ' Clear the Int flag.
INTCON = %11000000 ' Enable GIE, PEIE, falling edge.
PIE0 = %00010001 ' Enable IOCIE, INTE bits.
IOCAP = 0 ' Disable IOC rising edge A.
IOCAN = %00000100 ' Enable IOC falling edge A2.
ADCON0 = 0 ' No ADC.
ANSELA = %00000000 ' All Dig.
ANSELC = %00000000 ' All Dig.
CM1CON0 = 0 ' Comparators off.
FVRCON = %0 ' Disabled.
TRISA = %000100 ' A.2 pulled up, pushbutton to ground.
TRISC = %000000 ' C.5 serout to PC via 1k, C.4 led to ground via 1k.
LED var PORTC.4 ' Led via 1k to ground.
To_PC var PORTC.5 ' Serout to PC at 9600, Inv. Idles low, data goes high.
serI96 con 16468 ' 9600 Baud Inverted.
Include "MODEDEFS.BAS" ' Include Shiftin/out modes.
INCLUDE "DT_INTS-14 v1-2.bas" ' New version for Enhanced chips.
INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts.
ASM
INT_LIST macro ; IntSrce, Label, Type, ResetFlag?
INT_Handler ECIOC_INT, _PB, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE ECIOC_INT ; Enable the Int.
serout2 to_PC,seri96,[10,13,"I'm Alive!",10,13] ' Confirm.
Begin:
LED = 1 ' On.
pause 500 ' 2hz.
LED = 0 ' Off.
pause 500 ' 2hz.
goto begin ' Cycle.
'---[IOC - interrupt handler]---------------------------------------------------
PB: ' Pushbutton to get here.
if IOCAF.2 = 1 then ' Bit 1 (A.2) set.
serout2 to_PC,seri96,[10,13,"Int!",10,13] ' Testing.
endif
IOCAF = 0 ' Clear the Int flag.
@ INT_RETURN
end
Bookmarks