View previous topic :: View next topic |
Author |
Message |
Steve_Kos
Joined: 06 Sep 2006 Posts: 12
|
PWM ERROR Message |
Posted: Tue Apr 22, 2008 4:55 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 22, 2008 5:05 pm |
|
|
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);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Steve_Kos
Joined: 06 Sep 2006 Posts: 12
|
PWM ERROR Message |
Posted: Tue Apr 22, 2008 5:15 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|