PWM, step by step while configuring the SFR

Status
Not open for further replies.
Dear BigDog and ckshivaram thanks for reply

Let's say I want to ON one LED it's maximum bright and then gradually reduce it finally off
Can you explain using this example what is mean 10bit resolution
 


    V

    Points: 2
    Helpful Answer Positive Rating
You can think of it in 2 ways:

1) The duty cycle register is a 10-bit integer value that determines the duty cycle. CCPR1L contains the more significant 8 bits and CCP1CON<5:4> contain the 2 LSBs.
or
2) The duty cycle register is a 10-bit value with 8-bit integer and 2-bit decimal places.
So, you can think of CCPR1L storing the 8-bit integer value and CCP1CON<5:4> as the 2 decimal places.

Using the 2nd point:
The value of CCPR1L is to be between 0 and 255. DC1B1 and DC1B0 set the decimal places. Here's the setting:

DC1B1 = 0, DC1B0 = 0, Decimal point value = 0
DC1B1 = 0, DC1B0 = 1, Decimal point value = 0.25
DC1B1 = 1, DC1B0 = 0, Decimal point value = 0.5
DC1B1 = 1, DC1B0 = 1, Decimal point value = 0.75

So, if you set PR2 to 255, using CCPR1L = 127 and DC1B1 = 1, DC1B0 = 0, gives you exactly 127.5 for duty cycle control (50%).

If you compare and use this method, you will see that this is more or less the same thing as what bigdogguru has explained. However, I use this method, because, when coding, I like to keep it in my head that the value of the register representing the duty cycle has to be less than PR2 and a percentage of PR2, proportional to the duty cycle.

Bigdogguru has explained the first point here:
https://www.edaboard.com/threads/215581/#post930008

You can go to this page to read through previous discussions on this:
https://www.edaboard.com/threads/215581/

Hope this helps.
Tahmid.
 
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Mr:ckshivaram
Can I have some idea on this
I red gooligum tutorials and found timer0 that include watch crystal 32768 kHz
I know that this is 2 to the power15 but can anybody explain what important of this specific value so we can use another value like 65536 kHz

---------- Post added at 23:37 ---------- Previous post was at 23:01 ----------

ckshivaram
Can I have sample assembly codes using PWM for LED brightness change
 
Last edited:

Dear All
Can I have some idea on this
I red gooligum tutorials and found timer0 that include watch crystal 32768 kHz
I know that this is 2 to the power15 but can anybody explain what important of this specific value so we can use another value like 65536 kHz
 

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…