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+pic

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








pwm+pic
PostPosted: Sun Aug 06, 2006 12:19 pm     Reply with quote

hi
i want to make a 120khz pwm with timer2 of pic16f877a and with 7.67375mhz cristal and duty cycle 50% in ccs software.
please help me
thanks a lot
Ttelmah
Guest







PostPosted: Sun Aug 06, 2006 2:45 pm     Reply with quote

It'll actually be 119902Hz (you can't quite do 120KHz with the hardware, given your clock frequency), but the required setup lines are:

setup_timer_2(T2_DIV_BY_1,15,1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(32L);

Note the 'L'. This is important, since it makes the code use the extra two bits in the second register for setting the duty cycle.

Best Wishes
Guest








PostPosted: Mon Aug 07, 2006 11:59 am     Reply with quote

Hi
thanks alot for your guidance.
best regards
Moeini



Joined: 08 Aug 2006
Posts: 9

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Aug 08, 2006 1:32 am     Reply with quote

Hi
Kindly please explain for me about numbers in : setup_timer_2(t2_div_by_1,15,1)
and set_pwm1_duty(32L)
Best Regards
Ttelmah
Guest







PostPosted: Tue Aug 08, 2006 2:35 am     Reply with quote

Get AN564 from Microchip, and learn how the hardware you are trying to use works.

Best Wishes
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