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 CCS Technical Support

PIC16F88 - PWM resolution problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed Apr 06, 2011 9:32 am     Reply with quote

Value can't be bigger than the ((middle value+1) *4)-1.
So for a middle value of 255, maximum value is 256*4 = 1024 -1 = 1023. The '10 bit' maximum for the chip.
Your formula is basically right, except for needing a division by 100.

value = (%/100) *(250+1) *4 -1

100% = 1003
50% = 501

You've lost a '0' in your 100% calculation.

Best Wishes
luismramirez



Joined: 17 Feb 2011
Posts: 8

View user's profile Send private message

PostPosted: Wed Apr 06, 2011 11:47 am     Reply with quote

Thank you!

However, your formula has a "-1" at the end.
The one at the first page doesn't.

Which one is right and why??
luismramirez



Joined: 17 Feb 2011
Posts: 8

View user's profile Send private message

PostPosted: Wed Apr 06, 2011 6:35 pm     Reply with quote

ok. i got it.

thank you all ;)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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