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 100Khz 16f876-4Mhz

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



Joined: 22 Oct 2003
Posts: 22

View user's profile Send private message

PWM 100Khz 16f876-4Mhz
PostPosted: Thu Feb 05, 2004 8:14 pm     Reply with quote

Hi, Iīm new in this great world of pics.
I have 16f876-4Mhz and version 3.155
I donīt know how to get a frecuency of 100 Khz, and I want to control the duty cicle of the two PWM independents in the 16f876.
I only saw examples for frecuencies of 20 Khz or less.
Could you help me?
Thanks
kypec



Joined: 20 Sep 2003
Posts: 54

View user's profile Send private message

PostPosted: Fri Feb 06, 2004 9:55 am     Reply with quote

Here are my calculated settings for your desired 100 kHz PWM frequency
at Fosc=4 MHz.
Code:

   setup_timer_2(T2_DIV_BY_1,9,1);
   setup_ccp1(CCP_PWM); //PWM mode
   setup_ccp2(CCP_PWM); //PWM mode


However, keep in mind that the resolution which you get
at the configuration above is only some 5,32 bits which means:
Code:

set_pwm1_duty(0); //this is 0% duty cycle
set_pwm1_duty(40); //this is 100% duty cycle


Therefore, your effective range for PWM control is no more
than 41 discrete steps.
If this is too few for your application then you will have to
increase the oscillator frequency (up to 20 MHz) or
decrease the PWM frequency.

Have a nice day,

kypec
Helyos



Joined: 22 Oct 2003
Posts: 22

View user's profile Send private message

Thanks
PostPosted: Fri Feb 06, 2004 2:08 pm     Reply with quote

Thank you very much.
I will try it on monday when I can see it in oscilloscope.
Have a nice day
Helyos
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