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

Low Frequency PWM

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



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

Low Frequency PWM
PostPosted: Wed Jan 16, 2008 4:20 pm     Reply with quote

how does one get a low frequency?

i dont know how to get it to 50Hz i can get much less than 250Hz. do i have to go to a slower crystal? the adc sets the duty ratio.

Code:
#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)

void main() {
   int value;

   setup_ccp1(CCP_PWM);
         
   setup_timer_2(T2_DIV_BY_16, 249, 5);

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

  while( TRUE ) {
    value=read_adc();
    set_pwm1_duty(value);         
  }
 
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 16, 2008 5:18 pm     Reply with quote

You could use Timer0 (RTCC) to do software PWM. See this thread
for a link to the code.
http://www.ccsinfo.com/forum/viewtopic.php?t=30175
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