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

How to use 8 Mhz clock to generate slow PWM Frequencies

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



Joined: 29 Jun 2010
Posts: 10

View user's profile Send private message

How to use 8 Mhz clock to generate slow PWM Frequencies
PostPosted: Mon Aug 30, 2010 1:30 pm     Reply with quote

Hi,

I am using the PIC18F2480 and one of the goals of my project is to output PWM signals with slow frequencies (between 10 - 100 Hz). I know how to accomplish this through setting the internal oscillator frequency much lower (125Khz or 250Khz); however, I would like to be able to use the normal 8 Mhz clock frequency or somewhere in the Mhz range.

Would it be possible to hook up a slow external crystal or oscillator for the timer to use to generate the PWM signals, but to run the main program from the internal 8 Mhz clock? Or are there any other ways to accomplish this?

Thanks.

Here's some sample code I'm using to generate, if it helps:
Code:


void main()
{
    setup_oscillator(OSC_125KHZ);

   
   setup_timer_2(T2_DIV_BY_16, 255, 1);   
   setup_ccp1(CCP_PWM);

       while(1)
       {
        set_pwm1_duty(395L);
       }
}

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 30, 2010 1:36 pm     Reply with quote

Look at the software PWM routines in this thread, using #int_rtcc (Timer0):
http://www.ccsinfo.com/forum/viewtopic.php?t=37807
Brian



Joined: 29 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Tue Aug 31, 2010 1:28 pm     Reply with quote

Thanks very much. I posted an additional question on one of the threads already created here:

http://www.ccsinfo.com/forum/viewtopic.php?p=137266#137266

Thanks.
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