View previous topic :: View next topic |
Author |
Message |
ahmad
Joined: 09 Mar 2007 Posts: 6
|
unable to generate pwm using pic16f877a with pcm v4.024 |
Posted: Fri Mar 09, 2007 3:31 pm |
|
|
I write the following program to generate pwm and there is no output 0n rc2/ccp1 pin . what i have to do.
#include <16F877A.h>
#fuses HS
#fuses NOWDT
#fuses NOPROTECT
#fuses NOLVP
#fuses NODEBUG
#fuses NOPUT
#fuses NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#pragma zero_ram
#define motora PIN_B7
void main(void)
{
set_tris_c(0b00000000);
setup_timer_2(T2_DIV_BY_16,255,1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(512L);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1);
// TODO: USER CODE!!
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Mar 09, 2007 3:46 pm |
|
|
It works for me. I compiled your code with PCM vs. 4.024 and
programmed into a 16F877A with a 20 MHz crystal, on a PicDem2-Plus
board. I see a squarewave output signal on pin 17 of the 40-pin DIP
package. The frequency is 1.22 KHz. The duty cycle is 50%. |
|
|
Ttelmah Guest
|
|
Posted: Sat Mar 10, 2007 3:03 am |
|
|
I suggest he looks at the reply I already gave on the other thread where he asked the same question...
Best Wishes |
|
|
|