EasyManuals Logo

Microchip Technology PICkit 3 User Manual

Microchip Technology PICkit 3
102 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #69 background imageLoading...
Page #69 background image
Lessons
2012 Microchip Technology Inc. DS41628B-page 69
FIGURE 3-8: PWM ANALYSIS
The PWM period is specified by the PRx register. Timer 2/4/6 is used to count up to the
value in CCPRxH combined with two LSbs in CCPxCON. CCPRxL is used to load
CCPRxH. One can think of CCPRxL as a buffer which can be read or written to, but
CCPRxH is read-only. When the timer is equal to PRx, the following three events occur
on the next increment cycle:
1. TMRx is cleared
2. The CCPx pin is set
3. The PWM duty cycle is latched from CCPRxL into CCPRxH
The following steps should be executed in the order shown when configuring the CCP
module for standard PWM operation:
1. Select the Timer2/4/6 resource to be used for PWM generation by setting the
CxTSEL<1:0> bits in the CCPTMRS register.
2. Disable the CCPx pin output driver by setting the associated TRIS bit.
3. Load the PRx register with the PWM period value.
4. Configure the CCP module for the PWM mode by loading the CCPxCON register
with the appropriate values
5. Load the CCPRxL register and the DCxBx bits of the CCPxCON register, with the
PWM duty cycle value.
6. Configure and start Timer2/4/6:
a) Clear the TMRxIF interrupt flag bit of the PIRx register.
b) Configure the TxCKPS bits of the TxCON register with the Timer prescale
value.
c) Enable the Timer by setting the TMRxON bit of the TxCON register.
7. Enable PWM output pin.
This lesson uses a frequency of 486 Hz. Anything over ~60 Hz will eliminate any notice-
able flicker.
EXAMPLE 3-33:
The designer should also consider the PWM resolution.
EQUATION 3-3: PWM RESOLUTION
Two conditions must hold true for this lesson:
1. 10 bits of resolution
2. No flicker in LED
Period
Pulse Width
TMRx = 0
TMRx = CCPRxH:CCPxCON<5:4>
TMRx = PRx
;PWM Period = [PR2 + 1]*4*Tosc*T2CKPS = [255=6+ 1]*4*(1/500kHz) * 1
Resolution
4 PRx 1+log
2log
----------------------------------------- bits=

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Microchip Technology PICkit 3 and is the answer not in the manual?

Microchip Technology PICkit 3 Specifications

General IconGeneral
BrandMicrochip Technology
ModelPICkit 3
CategoryComputer Accessories
LanguageEnglish

Related product manuals