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 ERROR Message

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



Joined: 06 Sep 2006
Posts: 12

View user's profile Send private message

PWM ERROR Message
PostPosted: Tue Apr 22, 2008 4:55 pm     Reply with quote

I am trying to use a PIC16F685 to create a 38kHZ PWM signal. The clock is a 4MHz crystal, CCS 'C' is 4.071. When I add the following code:

Code:

      setup_ccp1 (CCP_PWM);                   // Configure CCP1 as a PWM
      setup_timer_2 (T2_DIV_BY_4, 25, 1);     // Setup for 38461 Hz     
      set_pwm1_duty (128);                    //  50% duty cycle


I get errors for all 3 lines, this is sample code I copied and changed the values around on. Am I missing something so obvious that after it is pointed out I will have to bow my head in shame?

Thanks for any assistance.

Steve
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 22, 2008 5:05 pm     Reply with quote

Quote:
I am trying to use a PIC16F685

It works for me. I compiled the following test program with vs. 4.071
with no errors. Try it. Also, I suggest that you start with the duty cycle
value shown in the code below.
Code:
#include <16F685.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock=4000000)

//==========================
void main()
{
setup_ccp1(CCP_PWM);                   
setup_timer_2(T2_DIV_BY_4, 25, 1);           
set_pwm1_duty(12);                     

while(1);
}
Steve_Kos



Joined: 06 Sep 2006
Posts: 12

View user's profile Send private message

PWM ERROR Message
PostPosted: Tue Apr 22, 2008 5:15 pm     Reply with quote

PCM Programmer ..... Thank you.

I had the project associated with another file that used a PIC with a different part without CCP/PWM.

Thanks again.

Steve
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