














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















Compare/Capture/PWM modules z 2 Modules available (ECCP1 and CCP2) z Registers involved are z 16 bit CCPRx (CCPR1, CCPR2) z CCPxCON(CCP1CON, CCP2CON) CCP2CON Register DCxB<1:0>: PWM Duty Cycle bit 1 and bit 0 for CCPx Module Capture mode: Unused. Compare mode: Unused. PWM mode: These bits are the two LSbs (bit 1 and bit 0) of the 10-bit PWM duty cycle. The eight MSbs 7 6 5 4 3 2 1 0
DCxB DCxB CCPxM CCPxM CCPxM CCPxM docsity.com
CCPx Module Mode Select bits 0000 = Capture/Compare/PWM disabled (resets CCPx module) 0001 = Reserved 0010 = Compare mode, toggle output on match (CCPxIF bit is set) 0011 = Reserved 0100 = Capture mode, every falling edge 0101 = Capture mode, every rising edge 0110 = Capture mode, every 4th rising edge 0111 = Capture mode, every 16th rising edge 1000 = Compare mode, initialize CCPx pin low; on compare match, force CCPx pin high (CCPxIF bit is set) 1001 = Compare mode, initialize CCPx pin high; on compare match, force CCPx pin low (CCPxIF bit is set) 1010 = Compare mode, generate software interrupt on compare match (CCPxIF bit is set, CCPx pin reflects I/O state) 1011 = Compare mode, trigger special event; reset timer; CCP2 match starts A/D conversion (CCPxIF bit is set) 11xx = PWM mode docsity.com
CCPRx register pair captures the 16-bit valueof the TMR1 or TMR3 register when an eventoccurs on the corresponding CCPx pin. z An event is defined as one of the following: z every falling edge z every rising edge z every 4th rising edge z every 16th rising edge docsity.com
docsity.com
16-bit CCPRx register value is constantlycompared against either the TMR1 or TMR3register pair value. z When a match occurs, the CCPx pin can be: z Driven high z Driven low z Toggled (high-to-low or low-to-high) z Remain unchanged (that is, reflects the state ofthe I/O latch) docsity.com
Both CCP modules are equipped with aSpecial Event Trigger z Special Event Trigger resets the Timerregister pair. z The Special Event Trigger for CCP2 can alsostart an A/D conversion. docsity.com
Generation of a Single pulse z Generation of multiple pulses z A periodic waveform with a certain duty cycle z Specific time delay docsity.com
Create pulses with variable widths on CCP pin. z Two factors to be considered while creatingvariable pulses z Period of Pulse z Duty Cycle z Period of Pulse
pwm = [(PR2) +1] 4 x N x T osc PR2 =
osc
pwm x 4 x N)- docsity.com
The CCPRxL is loaded into CCPRxH and theCCPx Pin goes HIGH to start the period z TMR2 value is compared with both PR2 andCCPRxH registers. z The TMR2 and CCPRxH are same, CCP pinis forced to low to end the duty cycle z As TMR2 matches with PR2 register, CCPpin goes high to end one period docsity.com
Period(PR2) Duty Cycle (CCPRxL) docsity.com
Register Associated with ECCP Module CCP1CON Register 7 6 5 4 3 2 1 0 P1M P1M DCxB DCxB CCPxM CCPxM CCPxM CCPxM docsity.com
docsity.com
docsity.com
PWM1CON Register is used to set the Dead-BandDelay z Dead-Band Delay is provided in terms ofMicrocontroller Instruction Cycles PWM1CON Register 7 6 5 4 3 2 1 0 PRSEN PDC PDC PDC PDC PDC PDC PDC docsity.com