CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PWM on the 16f877A

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 05, 2005 3:06 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 05, 2005 3:22 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Sun Jun 05, 2005 4:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 05, 2005 6:12 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 05, 2005 6:47 pm     Reply with quote

So you're probably using the TLVP or something similar to it.
http://www.finitesite.com/d3jsys/
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Sun Jun 05, 2005 7:37 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group