View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 28, 2007 5:51 pm |
|
|
Add the line shown in bold below to your program. Also add a #use rs232
statement, and a connection to the serial port on your PC (with a
MAX232-type chip).
Quote: |
printf("pwm_value = %lu \n\r", pwm_value);
set_pwm1_duty(pwm_value);
delay_ms(1000);
} // end of while |
Then watch the values that your program gives to the set_pwm1_duty()
function, as they are displayed in a terminal window on your PC.
This will help you to understand what the program is doing and help
you to debug it.
Also, try the PWM demo program shown in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=17729&start=1
This program should produce a PWM output. If it doesn't, you've
got other problems -- possibly with hardware or the compiler.
(Change the PIC, the #use delay() clock speed, and the oscillator
fuse to fit your hardware). |
|
|
quium
Joined: 19 Jan 2007 Posts: 27
|
|
Posted: Thu Mar 29, 2007 10:16 am |
|
|
Hi
I have tested my circuit by giving an external PWM instead of generating a PWM from the PIC and the circuit was working fine. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 29, 2007 11:21 am |
|
|
Quote: |
I have tested my circuit by giving an external PWM instead of generating
a PWM from the PIC and the circuit was working fine. |
But this thread isn't about the external circuits. You started the thread
by saying you had a problem with making the PIC generate PWM pulses.
Here is what you said:
Quote: |
But the problem is I am not getting any PWM at ccp1.
Is there any problem with my codes |
In my latest post, above, I suggested ways to trouble-shoot the
problem. I suggested that you display the PWM duty cycle value,
so you can see what duty cycle is being given to the CCS PWM
routines.
I also suggested that you use a simple test program (given in a link)
to see if your PIC can put out PWM pulses. This would confirm if
the PIC's CCP1 pin driver is working OK, and if the PIC is working OK,
and if the compiler is working OK.
I think I'm done with this thread. I don't think I can help any more. |
|
|
quium
Joined: 19 Jan 2007 Posts: 27
|
|
Posted: Fri Mar 30, 2007 9:19 am |
|
|
Thanks PCM programmer for the help, I actually left the master clear pin not connected , So I was having problem in getting the pwm, Now I have corrected it and its working fine
Many Thanks
Quium |
|
|
|