Introduction to Microcontrollers Lab Manual - Microchip
Introduction to Microcontrollers Lab Manual - Microchip
Introduction to Microcontrollers Lab Manual - Microchip
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
FIGURE 7-3: OUTPUT COMPARE BLOCK DIAGRAM<br />
The OCx outputs must be assigned <strong>to</strong> an available RPn pin before use.<br />
7.2.4 PWM Duty Cycle<br />
The PWM duty cycle is specified by writing <strong>to</strong> the OCxRS and OCxR registers. The<br />
OCxRS and OcxR registers can be written <strong>to</strong> at any time, but the duty cycle value is<br />
not latched until the period is complete. This provides a double buffer for the PWM duty<br />
cycle and is essential for glitchless PWM operation.<br />
Some important boundary parameters of the PWM duty cycle include:<br />
• If OCxR, OCxRS, and PRy are all loaded with 0000h, the OCx pin will remain low<br />
(0% duty cycle).<br />
• If OCxRS is greater than PRy, the pin will remain high (100% duty cycle).<br />
7.2.5 Edge-Aligned PWM Mode Operation<br />
When synchronization occurs, the following five events occur on the next increment<br />
cycle:<br />
• The timer is reset <strong>to</strong> zero and resumes counting<br />
• The OCx pin is set high (exception: if OCxRS = 0000, the OCx pin would not be<br />
set)<br />
• The OCxR and OCxRS Buffered registers are updated from OCxR and OCxRS<br />
• Interrupt flag, OCxIF, is set<br />
• When the timer and OCxR match, the pin would be set low. This match does not<br />
generate interrupts.<br />
Figure 7-4 depicts the output compare pin over time with OCxR = 0x0000 and OCxRS<br />
= 0x5000.<br />
2011 <strong>Microchip</strong> Technology Inc. DS51963A-page 53