View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 05, 2005 3:06 pm |
|
|
I took your program, cleaned up everything that was wrong with it,
got rid of everything that wasn't necessary for testing pwm, and
now it works. On pins 16 and 17 of my 40-pin DIP 16F877A,
I get a 38.7 KHz signals, with a 25% duty cycle. I'm running the
PIC at +5v.
Code: | #include <16f877A.h>
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use delay(clock=20000000)
int16 pwm_l, pwm_r;
void main()
{
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
setup_timer_2(T2_DIV_BY_1, 128, 1);
pwm_l = 128;
pwm_r = 128;
set_pwm1_duty(pwm_l);
set_pwm2_duty(pwm_r);
while(1); // Prevent PIC from going to sleep.
} |
|
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Sun Jun 05, 2005 3:22 pm |
|
|
Thanks, Now I know it's a bad pin. I wrote a little program to just toggle all the pins and PIN_C1 never moves. Very stange.
Thanks for all the replies.
Ringo _________________ Ringo Davis |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Jun 05, 2005 4:52 pm |
|
|
Ringo42 wrote: | I don't remeber the version but I bought it about 2 weeks ago. I have LVP in the fuses because that is how I program the chip. The chip is soldered down and I program it In-Circuit. I have the exact same code running on an 18f452 and it works fine. I'm going to try another chip at this point, I'm thinking it me be a bad pn or something.
Ringo |
In-circuit doesn't mean LVP. Most in-circuit programmers still apply Vpp to program the chips. This includes the ICD's. What did you do with the LVP pin? Either RB3 or RB5 depending on whether we are talking about the 16F877 or 18F452. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Sun Jun 05, 2005 6:12 pm |
|
|
I pull the LVP pin down with a 10K resistor. I program the chip using a simple programmer that connects to the printer port. The programmer is powered by teh board being programmed so I only need 5V, not the 12 or 15 that a typical programmer uses. It costs me 1 I/O, but it is worth it because of the simpleness of teh programmer.
Ringo _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Sun Jun 05, 2005 7:37 pm |
|
|
Same sort of thing. Mine uses a 74ls14 and 5 or 6 transistors. It works with several different software programs. I found the schematic online a couple years ago, but don't remeber where. Works great. If anyone needs a schematic let me know and I'll email it.
Ringo _________________ Ringo Davis |
|
|
|