Re: Pulse capture on 12F1822
It looks like you're monitoring for a positive going pulse that is caught by the first While/Wend but will stay there because the second While/Wend is waiting for it to go Positive again.
Change the second one to:
So now it is waiting for the pulse to go Low.
Or am I missing something to?... yup, thought the "Capture" was a pin, it's the interrupt. NM
Re: Pulse capture on 12F1822
Okay looked a little closer and "think" you need to enable the interrupts with:
Code:
INTCON = %11000000 'Enables global and all active peripheral interrupts
Re: Pulse capture on 12F1822
Louie, thanks for looking it over but I have to admit the mistake of operator error on my part :eek: I was using the sync output on the signal generator instead of the real output. Here is the working code.
Code:
#CONFIG
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__CONFIG _CONFIG2, _PLLEN_ON
#ENDCONFIG
OSCCON = %01110000 '8Mhz clock with 4x PLL (32MHz)
APFCON = %00000001 'CCP1 on RA5 (pin 2) T1G is RA4 (pin 3)
PORTA = 0 'RA5 all low
TRISA = %00100000 'RA5 input
CM1CON0 = 0 'turn off comparitor 1
CM1CON1 = 0 'configuration of comparator
MDCON = 0 'turn off data modulator
DACCON0 = 0 'turn off DAC
DACCON1 = 0 'turn off DAC
ANSELA = 0 'All pins digital
OPTION_REG = %10000000 'Weak pull ups off
FVRCON = 0 'Bunch of stuff disabled
CPSCON0 = 0 'Cap touch sensors off
CCP1AS = 0
PIE2 = 0
T1GCON = 0
INTCON = 0
DEFINE OSC 32
Include "modedefs.bas"
Symbol Capture = PIR1.2
T1 VAR word
PW VAR word
reload:
CCP1CON = %00000101
T1CON = 0
TMR1H = 0
TMR1L = 0
T1CON.0 = 1
Capture = 0
while !Capture
wend
T1.HighByte = CCPR1H
T1.LowByte = CCPR1L
CCP1CON = %00000100
Capture = 0
while !Capture
wend
PW.HighByte = CCPR1H
PW.LowByte = CCPR1L
PW = PW-T1
serout porta.4,N9600,[#PW,10,13]
goto reload
end