English
Language : 

PIC16LF18854 Datasheet, PDF (450/668 Pages) Microchip Technology – C Compiler Optimized RISC Architecture
PIC16(L)F18856/76
FIGURE 30-4:
SIMPLIFIED PWM BLOCK DIAGRAM
Duty cycle registers
CCPRxH CCPRxL
10-bit Latch(2)
(Not accessible by user)
Comparator
TMR2 Module
TMR2
R (1)
ERS logic
Comparator
R
Q
S
CCPx_pset
Rev. 10-000 157C
9/5/201 4
CCPx_out
To Peripherals
set CCPIF
PPS
RxyPPS
CCPx
TRIS Control
PR2
30.3.2 SETUP FOR PWM OPERATION
The following steps should be taken when configuring
the CCP module for standard PWM operation:
1. Use the desired output pin RxyPPS control to
select CCPx as the source and disable the
CCPx pin output driver by setting the associated
TRIS bit.
2. Load the PR2 register with the PWM period
value.
3. Configure the CCP module for the PWM mode
by loading the CCPxCON register with the
appropriate values.
4. Load the CCPRxL register, and the CCPRxH
register with the PWM duty cycle value and
configure the CCPxFMT bit of the CCPxCON
register to set the proper register alignment.
5. Configure and start Timer2:
• Clear the TMR2IF interrupt flag bit of the
PIR4 register. See Note below.
• Configure the T2CKPS bits of the T2CON
register with the Timer prescale value.
• Enable the Timer by setting the TMR2ON
bit of the T2CON register.
6. Enable PWM output pin:
• Wait until the Timer overflows and the
TMR2IF bit of the PIR4 register is set. See
Note below.
• Enable the CCPx pin output driver by
clearing the associated TRIS bit.
Note:
In order to send a complete duty cycle and
period on the first PWM output, the above
steps must be included in the setup
sequence. If it is not critical to start with a
complete PWM signal on the first output,
then step 6 may be ignored.
30.3.3 CCP/PWM CLOCK SELECTION
The PIC16F18855/75 allows each individual CCP and
PWM module to select the timer source that controls
the module. Each module has an independent selec-
tion.
As there are up to three 8-bit timers with auto-reload
(Timer2/4/6), PWM mode on the CCP and PWM mod-
ules can use any of these timers. The CCPTMRS0 and
CCPTMRS1 registers is used to select which timer is
used.
DS40001824A-page 450
Preliminary
 2016 Microchip Technology Inc.