English
Language : 

PIC16F1829LIN Datasheet, PDF (17/74 Pages) Micon Design Technology Corporation – 20-Pin, 8-bit Flash LIN/J2602 Microcontroller
PIC16F1829LIN
2.3 Routing CCP4 to a Pin
Normally, CCP4 uses RC6 as an output pin. This pin is
not available on the PIC16F1829LIN. This output
function can be re-routed to RC4, through the Data
Signal Modulator (DSM), as shown below.
; Setup CCP4
banksel PR2
movlw 0xFF
; set PWM for highest resolution
movwf PR2
banksel CCP4CON
movlw b'00001100'; set for PWM mode
movwf CCP4CON
movlw 0x80
; preload the duty cycle with a value
movwf CCPR4L
banksel CCPTMRS
movlw 0x00
; set Timer2 as clock source
movwf CCPTMRS
banksel PIR1
bcf
PIR1,TMR2IF; clear timer overflow flag
movlw b'00000101'; clock prescaler = 4
movwf T2CON
bsf
T2CON,TMR2ON; turn on Timer 2
; Setup DSM to route CCP4 to RC4
banksel MDCON
movlw b'11000000'; enable DSM, enable output pin
movwf MDCON
movlw 0x00
; modulation controlled by MCBIT
movwf MDSRC
movlw 0x87
; select CCP4 as carrier frequency and disable RC6
movwf MDCARL
movwf MDCARH
; modulation source does not matter because high and low carriers are the
; same.
 2012 Microchip Technology Inc.
Preliminary
DS41673A-page 17