Dave,
Thank you for the help. I have been trying to look through the registers, but obviously missing something.
Here is the stripped down core of the program. I was under the impression that DT_INTS took care of some of these registers, but manually included them in case I'm missing something.
The TMR code is working fine, I just can't the IOC to work.
Code:
'****************************************************************
' 16F18624,25,26
' ---------------u-----------------
' 5v pwr -1|VDD++ -- VSS |14- Gnd
' -2|RA5 RA0/ICSPDAT |13-
' Gge/Tac Drv -3|RA4 RA1 |12-
' -4|RA3/MCLR/vpp RA2 |11- Neutral > ECM
' Tach IN -5|RC5 RC0 |10- Neut LED
' -6|RC4 RC1 |9- VSS Led
' VSS -7|RC3 RC2 |8-
' ----------------------------------
'******************************************************************
#CONFIG
__config _CONFIG2, _MCLRE_OFF & _CP_OFF
#ENDCONFIG
INCLUDE "DT_INTS-16.bas" ; v1.10 Modified for 16F18326 IOC_INT
INCLUDE "ReEnterPBP.pbp" ; Include for DT_INTS. ver 3.4
' alias pins:
Nout var PORTA.2 ' Neutral switch output signal
TachDrv var PORTA.4 ' Tach Drive
N_LED VAR PORTC.0 ' LED for Neutral
VSS_LED VAR PORTC.1 ' LED for VSS
VSS var PORTC.3 ' Vehicle Speed Sensor output signal ON
TachIN var PORTC.5 ' Monitor ECM tachometer signal
PIE0 = %00010000 ' Enable interrupts (maybe not needed)
INTCON = %1100001 ' Global and peripheral INTS enabled, Rising edge
IOCCP = %00100000 ' Interrupt on change on RC5, tach input
T0CON0 = %10010000 ' TMR0 Postscale=0, 16 bit
T0CON1 = %01000000 ' Fosc/4, No Prescale
T1CON = %00000001 ' TMR1 prescale=2, clock=Fosc/4, TMR1=on
T1GCON = 0
PORTA = %00001000 ' Outputs except 3 for SpeedAdj
PORTC = %00100000 ' Outputs except 5 for Tach In input
TRISA = %00001000 ' Pins output(except 3 for Speed adj)
TRISC = %00100000 ' Outputs except 5 for Tach In input
ANSELA = 0
ANSELC = 0
;----[High Priority Interrupts]----------------------------------------
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler IOC_INT, _Capture, PBP, yes
INT_Handler TMR0_INT, _Timer0, PBP, yes
INT_Handler TMR1_INT, _Timer1, PBP, yes
endm
INT_CREATE ; Creates the High Priority interrupt processor
ENDASM
@ INT_ENABLE IOC_INT ; enable Capture interrupts
@ INT_ENABLE TMR0_INT ; enable Timer 0 interrupts
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
;-----------------------------------------------------------------------
Main:
GOTO Main
'---[IOC - interrupt handler]------------------------------------------
Capture: ' Enter here with Tach Pulse from ECM (IOC)
toggle VSS_led
toggle N_LED
pulsout tachdrv, 50 ' normal 4 cy tach, 500uS
@ INT_RETURN
'---[TMR0 - interrupt handler]-- --------------------------------------
Timer0: ' Set Idle flag if timer expires,
toggle Nout
@ INT_RETURN
'---[TMR1 - interrupt handler]----------------------------------------
Timer1:
toggle VSS
@ INT_RETURN
END
Bookmarks