kvrajasekar
New Member
Hi,
I am trying to use ccp in compare mode,i tried to set the out high on match,I got the output on timer1 and ccp register match,but i didnt get the cc1pif interrupt.and also it gets increment every instruction...
my code is follows,
list p=16f72 ;PIC16f72 is the target processor
INCLUDE "P16f72.INC"
;------------------------------------------------------------------------------------
__CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF ; configuration switches
org 0x00
goto main
org 0x04
btfsc PIR1,CCP1IF
goto pwm_loop
main bsf STATUS, RP0 ;Bank1
movlw b'00101111' ;Defining input and output pins
movwf TRISA ;Writing to TRISA register
movlw b'00001111' ;Defining input and output pins
movwf TRISB ;Writing to TRISB register 1-input,0-output
movlw b'00000000'
movwf TRISC
movlw 0x00
movwf ADCON1
bcf STATUS, RP0 ;Bank0
clrf PORTA ;potra,portb initially set to low
clrf PORTB
clrf PORTC
clrf CCP1CON
bsf INTCON,PEIE
clrf PIR1
bsf PIE1,CCP1IE
bsf INTCON,GIE ;Enbles interrupt.
bcf T1CON,TMR1ON
movlw d'8'
movwf CCP1CON
movlw 20
movwf CCPR1L
movlw 30
movwf CCPR1H
clrf TMR1H
clrf TMR1L
bsf T1CON,TMR1ON
wait goto wait //waiting for match
pwm_loop
end
please correct me if any wrong coding...
Regards,
Raja.
I am trying to use ccp in compare mode,i tried to set the out high on match,I got the output on timer1 and ccp register match,but i didnt get the cc1pif interrupt.and also it gets increment every instruction...
my code is follows,
list p=16f72 ;PIC16f72 is the target processor
INCLUDE "P16f72.INC"
;------------------------------------------------------------------------------------
__CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF ; configuration switches
org 0x00
goto main
org 0x04
btfsc PIR1,CCP1IF
goto pwm_loop
main bsf STATUS, RP0 ;Bank1
movlw b'00101111' ;Defining input and output pins
movwf TRISA ;Writing to TRISA register
movlw b'00001111' ;Defining input and output pins
movwf TRISB ;Writing to TRISB register 1-input,0-output
movlw b'00000000'
movwf TRISC
movlw 0x00
movwf ADCON1
bcf STATUS, RP0 ;Bank0
clrf PORTA ;potra,portb initially set to low
clrf PORTB
clrf PORTC
clrf CCP1CON
bsf INTCON,PEIE
clrf PIR1
bsf PIE1,CCP1IE
bsf INTCON,GIE ;Enbles interrupt.
bcf T1CON,TMR1ON
movlw d'8'
movwf CCP1CON
movlw 20
movwf CCPR1L
movlw 30
movwf CCPR1H
clrf TMR1H
clrf TMR1L
bsf T1CON,TMR1ON
wait goto wait //waiting for match
pwm_loop
end
please correct me if any wrong coding...
Regards,
Raja.