Sorry about that.
The code directly below works...that is it displays a T_off2 reading. The program waits for the CCP1 flag to set and then it jumps to the Display2 subroutine. What I wanted to have happen though, was for the program to jump to the Interrupt Handler routine and display the T_off reading. The code just below this code shows how I tried to do that, but nothing happens. In that code the instruction to jump to the Display2 subrouting is commented out. So I'm guessing that a CCP interrupt isn't supposed to make the program jump to the interrupt routine the same way that an RB0/Interrupt does... you have to do it like the first example below.
That is my question.
Thanks,
TDon
' PIC16F876A hardware connections
' PIC External
' ---- ---------
' RB1 LED Cathode
' RC2 Phototransistor Comparator Output to RC2/CCP1 pin
' ----[ Includes / Defines ]-------------------------------------------
@ DEVICE WDT_OFF
define OSC 4
include "modedefs.bas" 'include serout defines
' -----[ Variables ]-------------------------------------------------------
T_Off var Word ' Time in uS
T_off = 0 'Initialize to zero
' -----[ Initialization ]--------------------------------------------------
Init:
TRISB = %00000000 'PortB -all outputs
PORTB = %00000000 'Initialize PortB outputs low
TRISC.2 = 1 '(Pin 13) is input for CCP1 capture mode
CCP1CON = $05 'Capture mode, every rising edge
' -----[ Main Code ]-------------------------------------------------------
' Disable interrupts and clear interrupt flags
INTCON = $00 'Disable unmasked global interrupts (bit 7)
'Peripheral interrupts disabled (bit 6)
'TMR0 Interrupt disabled (bit 5)
'Disable RB0 interrupt (bit 4)
'Disable RB Port change interrupt (bit 3)
'TMR0 overflow flag cleared (bit 2)
'RB0 interrupt flag cleared (bit 1)
'RB port change flag cleared (bit 0)
PIR1 = $00 'Clear Interrupt flags (bit 0 only used by TMR1)
PIE1 = $00 'Peripheral Interrupt Enable Register ($00 is default)
'All individual bits are disabled
'including bit 0 TMR1 overflow interrupt
' Enable unmasked global interrupts and peripheral interrupts
INTCON = $C0
On interrupt goto IntHand
'Reset Timer 1 and turn it on
TMR1H = $00 'Reset timer to zero right after turning on
TMR1L = $00
T1CON = %00000001 'TMR1 on, prescaler=1, clock = (Fosc/4)
High PortB.1 'Turn on LED
Loop:
If PIR1.2 = 1 then Display2 'wait for the CCP1 flag to set, at RC2
goto Loop
Disable
IntHand:
T_Off.HighByte = TMR1H
T_off.Lowbyte = TMR1L
serout 2, T2400, ["T_Off = ", #T_Off, 13,10]
PIR1 = $00 'Clear Peripheral Interrupt Flag Register
INTCON.1=0
RESUME
ENABLE
Display2:
T_Off.HighByte = CCPR1H
T_Off.LowByte = CCPR1L
serout 2, T2400, ["T_Off2 = ", #T_Off, 13,10]
PIR1.2 = 0
INTCON.1=0
Return
END
----------------------------------------------------------------------------------
' PIC16F876A hardware connections
' PIC External
' ---- ---------
' RB1 LED Cathode
' RC2 Phototransistor Comparator Output to RC2/CCP1 pin
' ----[ Includes / Defines ]-------------------------------------------
@ DEVICE WDT_OFF
define OSC 4
include "modedefs.bas" 'include serout defines
' -----[ Variables ]-------------------------------------------------------
T_Off var Word ' Time in uS
T_off = 0 'Initialize to zero
' -----[ Initialization ]--------------------------------------------------
Init:
TRISB = %00000000 'All port b are outputs
PORTB = %00000000 'Initialize PortB outputs low
TRISC.2 = 1 '(Pin 13) is input for CCP1 capture mode
CCP1CON = $05 'Capture mode, every rising edge
' -----[ Main Code ]-------------------------------------------------------
' Disable interrupts and clear interrupt flags
INTCON = $00 'Disable unmasked global interrupts (bit 7)
'Peripheral interrupts disabled (bit 6)
'TMR0 Interrupt disabled (bit 5)
'Disable RB0 interrupt (bit 4)
'Disable RB Port change interrupt (bit 3)
'TMR0 overflow flag cleared (bit 2)
'RB0 interrupt flag cleared (bit 1)
'RB port change flag cleared (bit 0)
PIR1 = $00 'Clear Interrupt flags (bit 0 only used by TMR1)
PIE1 = $00 'Peripheral Interrupt Enable Register ($00 is default)
'All individual bits are disabled
'including bit 0 TMR1 overflow interrupt
' Enable unmasked global interrupts and Peripheral Interrupts
INTCON = $C0
On interrupt goto IntHand
'Reset Timer 1 and turn it on
TMR1H = $00 'Reset timer to zero right after turning on
TMR1L = $00
T1CON = %00000001 'TMR1 on, prescaler=1, clock = (Fosc/4)
High PortB.1 'Turn on LED
Loop:
'If PIR1.2 = 1 then Display2 'wait for the external interrupt on RC2
goto Loop
Disable
IntHand:
T_Off.HighByte = CCPR1H
T_off.Lowbyte = CCPR1L
serout 2, T2400, ["T_Off = ", #T_Off, 13,10]
PIR1 = $00 'Clear Peripheral Interrupt Flag Register
INTCON.1=0
RESUME
ENABLE
Display2:
T_Off.HighByte = CCPR1H
T_Off.LowByte = CCPR1L
serout 2, T2400, ["T_Off2 = ", #T_Off, 13,10]
PIR1.2 = 0
Return
Bookmarks