I am using 18f2221 with 32khz clk on T1OSC.
I want to prevent an interrupt from a pulse occurring on CCP1 (RC2) input until a ready input PB sw (RA0) is read.
I have turned off all interrupts (that I can think of!) and set the switch to read a low.
The problem is I cannot get the code to wait for the switch?
The interrupt appears to be occurring regardless the state of the switch that allow the interupts-on code?
the relevant code is here.
Non prioritized Interrupts.
So basically the problem is how to prevent the CCP1 interrupt from happening.
Everything tried so far does not seem to work.
Ideas welcome!
Max.
I want to prevent an interrupt from a pulse occurring on CCP1 (RC2) input until a ready input PB sw (RA0) is read.
I have turned off all interrupts (that I can think of!) and set the switch to read a low.
The problem is I cannot get the code to wait for the switch?
The interrupt appears to be occurring regardless the state of the switch that allow the interupts-on code?
the relevant code is here.
Non prioritized Interrupts.
Rich (BB code):
ORG 0x0000
ResetCode:
bra Start
ORG 0x0008
HighInt:
bra Intserv
Start:
bcf INTCON, GIE ;disable global interrupts
bcf INTCON, PEIE ;disable peripheral interrupts
bcf PIE1, 0 ;disable timer 1 interrupts
bcf PIE1, CCP1IE ;disable CCP1 interrupts
bcf PIR1, CCP1IE ;clear CCP1 interrupt flag
clrf flags
clrf CCP1CON ;CCP1 module off
movlw b'00001010' ;tmr1 prescaler and TMR1 setup,
movwf T1CON ; TMR1 off
clrf TMR1H ;clear timer 1 high
clrf TMR1L ;clear timer 1 low
movlw b'00011111' ;port A inputs
movwf TRISA
movlw 0x00
movwf TRISB ;Port B outputs.
clrf PORTB ;Clear port B
bsf TRISC, CCP1 ;CCP1 pin CCP input
WaitSW1:
btfsc PORTA, 0 ;wait for ready P.B.
bra WaitSW1 ; (0x00) resets/turns off CCP.
movlw b'00000101' ;capture on every rising edge
movwf CCP1CON ; CCP1 module on
bsf INTCON, GIE ;enable global interrupts
bsf INTCON, PEIE ;enable peripheral interrupts
bsf PIE1, TMR1IE ;enable Timer1 O.F. interrupts
bsf PIE1, CCP1IE ;Enable capture int
bsf T1CON, TMR1ON ;Turn TMR1 on
etc etc
Everything tried so far does not seem to work.
Ideas welcome!
Max.