pwm duty cycle of PIC18f4585

Status
Not open for further replies.
Have you looked at the data sheet?? it tells you how to do it on page 169.. it gives you the formula which depends on the OSC frequency and TMR2 scaler...
If you are lost post your osc frequency and TMR2 prescale value..etc and we can calculate it.

15.4.2 PWM DUTY CYCLE
The PWM duty cycle is specified by writing to the
ECCPR1L register and to the CCP1CON<5:4> bits. Up
to 10-bit resolution is available. The ECCPR1L
contains the eight MSbs and the CCP1CON<5:4> contains the two LSbs. This 10-bit value is represented by
ECCPR1L:ECCP1CON<5:4>. The following equation
is used to calculate the PWM duty cycle in time.
EQUATION 15-2:

PWM Duty Cycle = (ECCPR1L:ECCP1CON<5:4>) •TOSC • (TMR2 Prescale Value)
ECCPR1L and ECCP1CON<5:4> can be written to at
any time, but the duty cycle value is not latched into
ECCPR1H until after a match between PR2 and TMR2
occurs (i.e., the period is complete). In PWM mode,
ECCPR1H is a read-only register
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…