CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PWM resolution??

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
switchblademaster
Guest







PWM resolution??
PostPosted: Tue Jul 21, 2009 3:18 pm     Reply with quote

ok.......so I set up my timer 2 and pwm.
I am operating at an oscillator frequency of 16KHz
with a timer 2 of:
Code:

setup_timer_2(T2_DIV_BY_1,255,1);

thus my period of PWM is: 64uS which s equal to 15.625KHz

The resolution of my PWM becomes 10-bit.

My question is, if PR2=255 at maximum and I have a 10-bit resolution PWM (0-1024) which determines what value the duty cycle could be. How, could this be possible.

How does one utilize a 10-bit resolution if PR2 is only 8-bit?????

I means that every time that TMR2=PR2 the pulse goes high.......however

if TMR2 reaches value in the duty cycle register PWM goes low.

If PR2=255 and the duty cycle is a10-bit number (say 512) then PWM will never happen the output will remain high always.....

Can anybody help me??
siwtchblademaster
Guest







PostPosted: Tue Jul 21, 2009 3:20 pm     Reply with quote

ok.........i have been thinking is it that:

if i have a 10-bit resolution and say duty cycle is 512 and pr2=255 then pwm:

(512/1023)*255

is that it?????
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 21, 2009 3:30 pm     Reply with quote

Quote:
How does one utilize a 10-bit resolution if PR2 is only 8-bit?????

If you give the set_pwmx_duty() function a parameter that is larger than
8-bits, the compiler changes the generated code so that it's using 10-bit
mode.

This thread has more information:
http://www.ccsinfo.com/forum/viewtopic.php?t=17729&start=12
switchblademaster
Guest







PostPosted: Tue Jul 21, 2009 4:12 pm     Reply with quote

ok...........I realised that.
I simulated my code and it worked that way. Thanks man.....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group