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

PWM formula question
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
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Sun Feb 12, 2012 8:58 pm     Reply with quote

Ttelmah wrote:
The value for the period on timer2, can be up to 255, so with 255 selected, you get:
(255+1)*4 = 1024
and -1 gives 1023, as the full scale value.

If you select a lower count value for timer1, the frequency goes up, and the available resolution goes down. So with 127 selected, you get 511 as the maximum value (0 to 511 = 512 values - 9bit resolution), but double the frequency.
Sorry to dig this up again, but it seemed relevant;
I'm working with 8bit sound, so natively the values are 0-255, which fits in rather nicely with a period of 255.
But from the above, if I change this to be a 16bit value
Code:
setup_pwm_duty((int16)dutyValue); //?
does that mean by reducing the period to 63, I can keep my full 8bit range but quadruple the frequency?

PS. If moving to a PIC24F, it indicates that "Tcy = 2*Tosc"; I assume that means anywhere we see "*4" or "/4" we just substitute 2 for 4? So the above would double rather than quadruple?
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