Hello all, I'm having a bit of a problem using the CCP hardware to measure a pulse length on a 12F1822. I know where the program stalls but I can't figure out why. I debugged the program by lighting an LED at the various points. It never moves past the second while/wend loop when the trailing edge of the pulse is supposed to trigger an interrupt. Any ideas on why the interrupt is never happening? Thanks.
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 PIE1.2 = 1 PIE2 = 0 T1GCON = 0 DEFINE OSC 32 Include "modedefs.bas" Symbol Capture = PIR1.2 T1 VAR word PW VAR word reload: low porta.2 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,"uS High",13,10] goto reload end




Bookmarks