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

PIC16F876 @ 20MHZ

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
greg s
Guest







PIC16F876 @ 20MHZ
PostPosted: Wed Dec 29, 2004 5:20 pm     Reply with quote

I am trying to run a PIC16F876 20/SP at 20Mhz
I have my Use_clock(20000000) in the code and the board works fine with a 4MHz crystal. Are there problems with running this chip at 20MHz?
Also, with the 4MHz crystal, I can run the UART at 38400 8-N-1 but it will not run at 57600. According to the microchip data sheet, 57600 has the same % error as say 19200 that also works with the 4Mhz crystal. The way I am checking the UART is a simple connection to hyperterminal right now. I am setting a pin high at the begining on the serial transfer then low at the end and using a scope I know the code is running but no data to the hyperterminal except for the occasional garbled character set.
Anythoughts? I have tried all crystal options LP, XT and HS. My 4Mhz crystal uses XT.
I am running my CCS PCM compiler from MPLAB V5.70
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 29, 2004 5:52 pm     Reply with quote

I have a question. Are you using a 4 MHz crystal with the #use delay
statement set to 20 MHz ? That won't make the PIC run at 20 MHz.
To run at 20 MHz, you need a 20 MHz crystal.
gregs s
Guest







pic16f876 @20 Mhz
PostPosted: Wed Dec 29, 2004 7:35 pm     Reply with quote

yes, I am using the correct use_clock with the correct crystal, I am tring to get a 20Mhz crystal to work with this chip that runs fine when set up with a 4mhz crystal and correct code.
The UART part of this question is posed when the appropriate code and crystal is used as well.
20mhz crystal and code= no UART at any speed and no chip operation
4 mhz crystal and code = no uart above 38400.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 29, 2004 8:52 pm     Reply with quote

1. What is the value of the capacitors that you are using with the crystal ?

2. What is the manufacturer and what is the part number of the 20 MHz
crystal ?

3. Post the markings which are on the top of the PIC chip.
Don't post the part number that you ordered. Post the actual
markings on the chip that you have.

4. What voltage are you using for the PIC ?
greg s
Guest







pic16f876 @20mhz
PostPosted: Thu Dec 30, 2004 7:57 am     Reply with quote

to quickly answer the posted questions.

1. 15pf I have tried 33 pf
2. digikey part number X195-nd manufacturer: ECS
3. Actual markings on Pic: PIC16F876-20/SP
4. Running at 5V
Also, I have a ground plane under the crystal and pic.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

Re: pic16f876 @20mhz
PostPosted: Thu Dec 30, 2004 8:02 am     Reply with quote

greg s wrote:
to quickly answer the posted questions.

1. 15pf I have tried 33 pf
2. digikey part number X195-nd manufacturer: ECS
3. Actual markings on Pic: PIC16F876-20/SP
4. Running at 5V
Also, I have a ground plane under the crystal and pic.


So your #fuses statment has "HS" when using the 20MHz and "XT" for the 4MHz right?

Check that you aren't accidentally grounding on or both of the crystal pins with your ground plane. Stranger things have happened.

You have good electrical contact between the pins of the crystal and the OSC1 and OSC2 pins of the PIC. You aren't trying to use the crystal as a self-contained oscillator and just connected one pin, right?

15pF should have been "OK" but there are proceedures you can follow for optimizing the capacitor values based on actual circuit board parasitics. But until you get something to run, I wouldn't worry too much about the difference between using 15pF vs 18pF vs whatever.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
greg s
Guest







PIC16F876 @20 mhz
PostPosted: Thu Dec 30, 2004 9:51 am     Reply with quote

yes, I am using the HS for the 20 mhz and XT for the 4 mhz, tried them all actually.
I do not have a ground connection where it should not be when using the 20mhz crystal.
Also, I have good electrical contact between the PIC pins and the crystal/caps.
One note, the whole 20mhz problem would go away if I could get a UART speed above 38400 to work with the 4 mhz cyrstal. I am going through a MAX232AEPE on the RS232 side, but when connecting above 38400, I just get trash.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

PostPosted: Thu Dec 30, 2004 10:05 am     Reply with quote

ECS brand crystals are generally pretty good but if it took a good bash it may have a broken bond wire inside the case. Do you have a 2nd crystal to try?
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Ttelmah
Guest







Re: PIC16F876 @20 mhz
PostPosted: Thu Dec 30, 2004 10:13 am     Reply with quote

greg s wrote:
yes, I am using the HS for the 20 mhz and XT for the 4 mhz, tried them all actually.
I do not have a ground connection where it should not be when using the 20mhz crystal.
Also, I have good electrical contact between the PIC pins and the crystal/caps.
One note, the whole 20mhz problem would go away if I could get a UART speed above 38400 to work with the 4 mhz cyrstal. I am going through a MAX232AEPE on the RS232 side, but when connecting above 38400, I just get trash.

The key here, is the chip data sheet.
At 57600, with a 4MHz crystal, the error is 8.51%. The normal figure for the worst error 'allowable', is around 4%.
However changing to 3.6864MHz, allows 57600, with no error (and most other standard baud rates as well). At 20Mhz, the error, is still 3.34%, and as such is pretty 'borderline'. 16MHz, is 'better' in this regard, giving 2.13%.
The odds are your problem is just the crystal. The requirements do become tighter at higher speeds, and many of the crystals used at 4MHz, won't work, when ones from the same manufacturer are tried at higher rates. Read the application note on the MicroChip site, about crystal selection. It can (at times), make 'worrying' reading, but also tells you how to select the right crystal.

Best Wishes
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