The PIC is 16F8777 at 20 Mhz
I try to change :
Disable
interr:
...
....
...
Enable
return
to
interr:
Disable
...
....
...
Enable
return
but i have problem to ccp module to capture period of 1 ms the measure are instable but without interrupt the measure are correctly
This program work fine
' Main Program Loop
' -----------------
Loop:
'
' Sample Section
' --------------
TMR1L=0 ' Reset Timer
TMR1H=0 ' Remember Timer is OFF
capture=0 ' Reset Capture Flag
CCP1CON = %00000100
' Enable the CCP1 capture, falling edge
While Capture=0:Wend
' Junk 1st Result
T1CON.0=1
' Enable Timer
capture=0 ' Reset Capture Flag
While Capture=0:Wend
' Wait for 2nd Result
period.lowbyte = CCPR1L
period.highbyte = CCPR1H
' Store the captured value in period variable
T1CON.0=0 ' Timer is OFF
CCP1CON=0 ' Capture is OFF
Hserout[period.highbyte,period.lowbyte]
pause 500
Goto Loop
This program don't work fine
INTCON = %11100000
PIE1=%00101111
ON INTERRUPT GoTo interr
mainloop:
' Main program
GoTo mainloop
' Interrupt Header
Disable
interr:
'********************************************
'Interrupt PWM
IF PIR1.1=1 Then ' TMR2 to PR2 interrupt flag
PIR1.1=0
' Interrupt routine
endif
'************************************
'Interrupt Period
If pir1.2=1 then
pir1.2=0
If state=0 then
T1CON.0=1 ' Enable Timer
pir1.2=0 ' Reset Capture Flag
state =1
CCP1CON = %00000101
else
' Store the captured value in period variable
T1CON.0=0 ' Timer is OFF
CCP1CON=0 ' Capture is OFF
Period.lowbyte = CCPR1L
Period.highbyte = CCPR1H
TMR1L=0 ' Reset Timer
TMR1H=0 ' Remember Timer is OFF
pir1.2=0 ' Reset Capture Flag
CCP1CON = %00000101
state=0
endif
endif
'************************************
'Interrupt TMR0
If INTCON.2=1 then
' Interrupt routine
INTCON.2=0
endif
'************************************
'Interrupt Network
IF PIR1.5=1 Then
' Interrupt routine
endif
Resume
Enable
Bookmarks