Noob question with PWM

Status
Not open for further replies.

kasamiko

Full Member level 3
Joined
May 23, 2004
Messages
154
Helped
16
Reputation
32
Reaction score
18
Trophy points
1,298
Location
Philippines
Activity points
1,121
hi,

can somebody tells me how this guy got the value of

CCPR1L = 25 and
CCP1CON = 12

here's part of the code:



I tried using the online PWM calculator which can be found here:

PIC PWM Calculator & Code Generator

but got CCPR1L and CCP1CON values as follows:

CCPR1L = 0b00011000 or 24 decimal
CCP1CON = 0b00111100 or 60 decimal

which of them are correct?

TIA



`

---------- Post added at 11:02 ---------- Previous post was at 10:19 ----------



11xx = PWM mode

Well I think this is constant for CCP1CON to be 12 for PWM mode?
 

first check datasheet for formula

given things are:
Fosc=20MHz F=40KHz, DC=20% TMR2 prescaler =1

PR2=[RWM period/4*Tosc]-1 =[25us/.02us]-1=124

NOW

CCPR1L:CCP1CON <4:5>= PWM DC /Tosc * TMR2 prescaler =.2*25us/.05us =100d =1100100

so CCP1CON<4:5>=0 and CCPR1L=11001 =25d

so it gives CCP1CON=0x0C

hope it will help u
 
Last edited:
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…