Andrew83
Joined: 16 Sep 2008 Posts: 51
|
Simple PWM problem ! Any ideas ? |
Posted: Sat Jan 17, 2009 1:27 am |
|
|
Hello everybody !
I have a problem with a simple PWM setup.
I'm trying to generate a 38 KHz pwm pulse, using a PIC18f452 @ 4 MHz (CCS C compiler version 4.057).
However, when i measure the pulse with PICKIT 2 logic analizer, the output doesn't correspond to 38 KHz.
Here is the output from pickit analizer :
http://rapidshare.com/files/184712495/test1.bmp.html
And here is the code of my simple application:
Code: |
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
void main()
{
setup_ccp1(CCP_PWM);
setup_timer_2(T2_DIV_BY_1, 25, 1);
set_pwm1_duty(13);
while(1);
}
|
I've placed the capacitors as near to the crystal as possible, as it is specified in the datasheet of the pic. The values of the capacitors are correct.
What could be the problem ??
Thank you all !! |
|