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 on 16F877A, how to change the duty cycle

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 12, 2006 1:26 am     Reply with quote

One way to simplify it is to just cut out the options and the RS-232 stuff:
Code:

#include <16F877.h>
#device adc=8
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)

void main()
{
int8 value;
   
setup_ccp1(CCP_PWM);

setup_timer_2(T2_DIV_BY_4, 127, 1);

setup_port_a(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);

while(1)
  {
   value = read_adc();

   set_pwm1_duty(value);
  }

}
hongtao



Joined: 09 Mar 2006
Posts: 4
Location: Shanghai China

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 15, 2006 5:26 am     Reply with quote

Hi

PCM programmer, thanks. It works. I can use it in my program.I find so

many post about PWM, after finishing my graduation project, I will write a

post to make a summary or a index, may be it will be easy to check.

谢谢!!
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