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 in 18f8722 problem

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



Joined: 12 Mar 2012
Posts: 6

View user's profile Send private message

pwm in 18f8722 problem
PostPosted: Mon Mar 12, 2012 5:54 am     Reply with quote

Hi all
I am using the version 4.114.
My Crystal is 10MHZ. I am using PLL.

When I want to generate 5khz PWM with 50% duty cycle I don't see anything on the oscilloscope:
Code:

SETUP_CCP2(CCP_PWM );
setup_timer_2(T2_DIV_BY_16, 124, 1);      //5khz
set_pwm2_duty(250);


When I generate 10khz everything is ok.
Please guide me for the problem.
Code:

SETUP_CCP2(CCP_PWM );
setup_timer_2(T2_DIV_BY_4, 249, 1);      //10khz
set_pwm2_duty(500);

Regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 12, 2012 11:44 am     Reply with quote

Add an 'L' to the end of 250, as shown below:
Quote:

set_pwm2_duty(250L);


For information on why this is done, read the links on 10-bit PWM in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=45968&start=1
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