Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM - Duty cycle - Is finer adjustment possible?

Status
Not open for further replies.

atferrari

Full Member level 4
Joined
Jun 29, 2004
Messages
237
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Location
Buenos Aires - Argentina
Activity points
1,996
Today I started to experiment with PWM in a 16F877. Got both PWM modules working in minutes.

While period can be finely ajusted with 10-bits precision, the duty cycle seems more complicate due to the two LSB in CCP1CON<5:4>.

I have no specific application in mind but when tried to increase/decrease the duty cycle value I've realized that trying to change it down to the LSB would demand too much code other than INCF / DECF.

For an eventual application requiring a fast adjustment, is it any way to do it or we have to accept adjusting only the value in CCPR1L?

Agustín Tomás
 

atferrari,


What do you mean too much code ?

If you mean that the code takes too long to modify the PWM and makes cracks and pops you can make a shadow register in software. copy the PWM controll register into a general purpose register modify what you want in it, then copy that back.to the PWM controll register.

Maui
 

Hi Maui,

I asume that you know the 16F877. To control duty cycle, there is one 8-bit register plus 2 more (the LSB) which go in another register. Together they make for a 10 bit value.

My counter should then be 16-bit from from where I should take the two LSB to insert in the CCP1CON <5:4> and the 8 left into CCPR1L.

However it's done, it always seems too much code. Thinking of something simpler I didn't even tried to write that.

Agustín Tomás
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top