Here's what I finally worked out:
Code:'*** DT_INTS_14.pbp changed and renamed DT_INTS_16F1xxx.pbp (AND put in the right folder! ****************** '*** bottom 2 lines apply to program below ******* '........... ASM asm = 0 Asm = 0 ASM = 0 pbp = 1 Pbp = 1 PBP = 1 yes = 1 Yes = 1 YES = 1 no = 0 No = 0 NO = 0 #define ALL_INT INTCON,GIE, INTCON,GIE ;-- Global Interrupts * #define T1GATE_INT PIR1,TMR1GIF, PIE1,TMR1GIE ;-- Timer1 Gate * #define INT_INT PIR0,INTF, PIE0,INTE ;-- External INT #define IOCA0_INT IOCAF,IOCAF0, PIE0,IOCIE ; RA0 IOC+ (MR) #define IOCA1_INT IOCAF,IOCAF1, PIE0,IOCIE ; RA1 IOC+ (MR) #define IOCA2_INT IOCAF,IOCAF2, PIE0,IOCIE ; RA2 IOC+ (MR) #define IOCA3_INT IOCAF,IOCAF3, PIE0,IOCIE ; RA3 IOC+ (MR) #define IOCA4_INT IOCAF,IOCAF4, PIE0,IOCIE ; RA4 IOC+ (MR) #define IOCA5_INT IOCAF,IOCAF5, PIE0,IOCIE ; RA5 IOC+ (MR) #define IOCC0_INT IOCCF,IOCCF0, PIE0,IOCIE ; RC0 IOC+ (MR) #define IOCC1_INT IOCCF,IOCCF1, PIE0,IOCIE ; RC1 IOC+ (MR) #define IOCC2_INT IOCCF,IOCCF2, PIE0,IOCIE ; RC2 IOC+ (MR) #define IOCC3_INT IOCCF,IOCCF3, PIE0,IOCIE ; RC3 IOC+ (MR) #define IOCC4_INT IOCCF,IOCCF4, PIE0,IOCIE ; RC4 IOC+ (MR) #define IOCC5_INT IOCCF,IOCCF5, PIE0,IOCIE ; RC5 IOC+ (MR) #define CCP1_15313_INT PIR6,CCP1IF, PIE6, CCP1IE ; (MR) #define CCP2_15313_INT PIR6,CCP2IF, PIE6, CCP2IE ; (MR) '................
Code:'**************************************** '* Name : 16F15313 test-1.BAS '* Author : '* Notice : Copyright (c) 2020 '* : All Rights Reserved '* Date : 9/19/20 '* CCP1 used for Capture, 16F15313 has two '*THIS REV: WORKING ' 16F15313 ' ---------------u------------- ' -|vdd (+) vss(-) |- ' VSS out -|RA5 RA0/pgd |- Pulse in * ' -|RA4 RA1/pgc |- Neut Out ' -|A3/Vpp/MCLR RA2/ |- ' ---------------------------- '**************************************************************** include "DT_INTS-16F1xxx.pbp" ; Base Interrupt System. Ver 1.22 INCLUDE "ReEnterPBP.pbp" ; Include for DT_INTS. ver 3.4 '***************************************************************** define OSC 8 ' tell the compiler that the OSC is 8MHz OSCEN = %01000000 ' HFINTOSC OSCFRQ = %00000011 ' 8MHz '********* CCP1PPS = 0 ' assigns CCP1 Input to RA0; '********* PulseIN var PORTA.0 ' LED1 var PORTA.1 ' LED2 var PORTA.5 ' PORTA = %00001001 ' Outputs (except 0&3) = 0 on bootup TRISA = %00001001 ' Pins output(except 0&3) ANSELA = %00000000 ' Set all digital ';----[High Priority Interrupts]---------------------------------------- ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler CCP1_15313_INT, _Capture, PBP, yes ; endm INT_CREATE ; Creates the High Priority interrupt processor INT_ENABLE CCP1_15313_INT ENDASM CCP1CON = %10000101 'capture mode, capture on rising edge Main: pause 1000 GOTO Main '---[CCP1 - interrupt handler]------------------------------------------ Capture: ' Enter here with PulseIN (CCP1) if CCP1CON = %10000101 then ' If rising edge capture, then toggle LED1 goto Over_CCP ' Done, exit endif if CCP1CON = %10000100 then ' If falling edge capture, then toggle LED2 CCP1CON = %10000101 ' switch back to rising edge endif Over_CCP @ INT_RETURN END




Bookmarks