Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Objectives
CCP/ECCP/PWM Modules
CCP: compare/capture module ECCP: Enhanced CCP PWM: Pulse width module Depending upon the family PIC18 may have 0 to 5 CCP modules. PWM is the feature of CCP CCP are enhanced in the recent years and are termed as ECCP
CCP programming
PIC18 timers are used as follows:
Usage of timers is different for different CCP features. T3CON register is used to chose the timer for CCP modes.
CCP registers
Each CCP has three registers associated with it. CCPxCON: 8-bit control register CCPRxL and CCPRxH: Can be used as
low and high byte of 16-bit register 16-bit compare register 16-bit capture resigter 8-bit duty cycle register by PWM. ** but not all at the same time.
CCPxCON register
low and high byte of 16-bit register 16-bit compare register 16-bit capture register 8-bit duty cycle register by PWM.
driven high driven low toggled (high-to-low or low-to-high) remain unchanged (that is, reflects the state of the I/O latch)
T3CON register
T3CON register
Example
Program 15-1
every falling edge every rising edge every 4th rising edge every 16th rising edge
PIR1 register
PIR1 register
Program 15-2
PWM
PWM: Pulse-width modulation (PWM), or pulseduration modulation(PDM), is a modulation technique that conforms the width of the pulse, formally the pulse duration, based on modulator signal information. Its main use is to allow the control of the power supplied to electrical devices, especially to inertial loads such as motors.
PWM mode
Allows us to create pulses with variable widths. In Pulse Width Modulation (PWM) mode, the CCPx pin produces up to a 10-bit resolution PWM output. Since the CCP2 pin is multiplexed with a PORTB or PORTC data latch, the appropriate TRIS bit must be cleared to make the CCP2 pin an output.