Specifications
dsPIC33F/PIC24H Family Reference Manual
DS70323E-page 43-46 © 2008-2012 Microchip Technology Inc.
Based on Equation 43-4, while operating in the PTPER register or the PHASEx and SPHASEx
registers, the register value to be loaded is shown in Example 43-8.
Example 43-8: PWM Time Period Calculation
The maximum available PWM period resolution is 1.04 ns. The PWM Input Clock
Prescaler (Divider) Select bits, PCLKDIV<2:0> (PTCON2<2:0>/STCON2<2:0>) determine the
type of PWM clock. The timer/counter is enabled or disabled by setting or clearing the PWM
Module Enable bit, PTEN (PTCON<15>). The PMTMR/SMTMR timer is also cleared using the
PTEN bit (PTCON<15>).
If the Enable Immediate Period Updates bit, EIPU (PTCON<10>/STCON<10>) is set, the active
master period register (an internal shadow register) is updated immediately instead of waiting for
the PWM cycle to end. The EIPU bit affects the PMTMR/SMTMR master time base. The clock
prescaler selection is shown in Example 43-9. The PWM time period selection is shown in
Example 43-10. The PWM time period initialization is shown in Example 43-11.
Example 43-9: Clock Prescaler Selection
Example 43-10: PWM Time Period Selection
Example 43-11: PWM Time Period Initialization
Where,
M1
=
16
REFCLK
= 7.49 MHz
7.49 MHz
1
*
16
ACLK
=
= 119.84 MHz
N
=
1
Desired PWM Period =
1
119.84 MHz
- 8
=
9579
Desired PWM Switching Frequency
PCLKDIV
=
1:1
1
Desired PWM Switching Frequency = 100 kHz
10
μ
s
*
8
*
PTPER, STPER, PHASEx, SPHASEx =
Where,
/* Select PWM time base input clock prescaler */
/*
Choose divide ratio of 1:2, which affects all PWM timing operations */
PTCON2bits.PCLKDIV = 1;
/* Select time base period control */
/* Choose one of these options */
PWMCON1bits.ITB = 0; /* PTPER provides the PWM time period value */
PWMCON1bits.ITB = 1; /* PHASEx/SPHASEx provides the PWM time period value */
/* Choose PWM time period based on FRC input clock */
/* PWM frequency is 100 kHz */
/* Choose one of the following options */
PTPER = 9579; /* When PWMCONx<9> = 0 */
PHASEx = 9579; /* When PWMCONx<9> = 1 */
SPHASEx = 9579; /* When PWMCONx<9> = 1 */