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

Setting up 16F88 with external 20MHz oscillator

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



Joined: 11 Dec 2005
Posts: 3

View user's profile Send private message

Setting up 16F88 with external 20MHz oscillator
PostPosted: Sun Dec 11, 2005 4:07 pm     Reply with quote

Hi guys, sorry this is such a fundamental question. I have searched for an answer previously posted, and I apologise if I have missed it.

I am just wondering if anyone has any advice on setting up a 16F88 with an external 20MHz oscillator.

So far I have
#use delay(clock=20000000)
#fuses EC_IO, HS, NOWDT, NOLVP, NOMCLR, NOPUT

Do I need to set the osccon to anything? Also I am doing this on breadboard with a 2pin crystal, am I right in connecting both pins to 0V with very small capacitors (eg 15nf)? Is the breadboard likely to give me trouble at these speeds?

Many thanks for any help you can offer guys, thankyou

Tom
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 11, 2005 4:18 pm     Reply with quote

When you say "oscillator", do you mean something that looks like this:
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/ECS-TTL%20CLOCK%20OSCIL.jpg

Or do you mean like this:
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/HC-49US.jpg


The first one is an oscillator. The 2nd one is a crystal.
Which do you have ?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Dec 11, 2005 6:07 pm     Reply with quote

Quote:

am I right in connecting both pins to 0V with very small capacitors (eg 15nf)?


No, it's wrong. Here you will find how to connect the crystal to a PIC.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_02chapter.htm

Quote:

Is the breadboard likely to give me trouble at these speeds?


Lets assume that a breadboard is not the best choise for high freq, it should run ok
but keepping the wires as short as possible.


Humberto
spikit_uk



Joined: 11 Dec 2005
Posts: 3

View user's profile Send private message

PostPosted: Mon Dec 12, 2005 6:15 am     Reply with quote

Hi again guys, many thanks for your help and links.

I think it is actually a two pin crystal; a CMAC CK.

Humberto, your link does seem to suggest typing both pins to 0v with capacitors; although I was a few orders of magnitude out with 15nF; as the link seems to suggest 30pF!

I may switch to a 3pin with internal capacitors for simplicity however.

So can you guys by any chance suggest a fuse/osccon configuration for such a system?

Thanks again fellas, Tom
Ttelmah
Guest







PostPosted: Mon Dec 12, 2005 6:50 am     Reply with quote

If it is a two pin crystal, then the mode _must_ be HS, not 'EC', or 'EC_IO'. These latter modes are for external _oscillators_. Now the capacitor value that should be used, will depend on the crystal, and should be specified by the manufacturer. In fact it'll probably run OK, with the capacitor fairly well 'out of spec', but this will cause the frequency to be out of the manufacturers specification. If you get the value 'right' (and remember that you also have to include the capacitance of the pin, and the traces in the calculation - with a 'breadboard', the latter may well already be larger than required...),the crystal will then give it's specified accuracy.
Basically the oscillator modules, are normally for pin devices, with only three connected. They have a crystal, and solid state oscillator/buffer all built into the one package, and produce a square wave output that can be fed directly into the 'OSC1/CLKIN' pin. For these, EC, or EC_IO, are the right fuse settings (the former produces a clock output on OSC2, that can be used to feed other devices, the latter makes this pin available for I/O.

Best Wishes
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Dec 12, 2005 7:27 am     Reply with quote

Quote:

Humberto, your link does seem to suggest typing both pins to 0v with capacitors


I preffer to show a circuit.
The phrase:
"connecting both pins to 0V with very small capacitors"
sound quite confusing to me.


Quote:

although I was a few orders of magnitude out with 15nF; as the link seems to suggest 30pF!

Pls read the datasheet.
You will find all you are asking in Page 35,
4.0 OSCILLATOR CONFIGURATIONS




Quote:

So can you guys by any chance suggest a fuse/osccon configuration for such a system?


If you are going to use a crystal like this one (thanks PCM Programmer)

http://rocky.digikey.com/WebLib/ECS/Web%20Photos/HC-49US.jpg

....your header should look like this:

Code:

#include <16F88.h>
#device adc=8   // or #device adc=10

#FUSES NOWDT            //No Watch Dog Timer
#FUSES HS               //High speed Osc (> 4mhz)
#FUSES PUT              //Power Up Timer
#FUSES MCLR             //Master Clear pin enabled
#FUSES BROWNOUT         //Reset when brownout detected
#FUSES NOLVP            //No low voltage prgming, B3(PIC16) 
#FUSES NOCPD            //No EE protection
#FUSES NOWRT            //Program memory not write protected
#FUSES NODEBUG          //No Debug mode for ICD
#FUSES NOPROTECT        //Code not protected from reading
#FUSES FCMEN            //Fail-safe clock monitor enabled
#FUSES IESO             //Internal External Switch Over mode enabled

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A2,ERRORS)


void main()
{
// Select according to yours need.

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(VREF_LOW|-2);
   setup_oscillator(False);

   // your code
   // ............
   // ............
   // ............
}


Hope this help.

Humberto
spikit_uk



Joined: 11 Dec 2005
Posts: 3

View user's profile Send private message

PostPosted: Tue Dec 13, 2005 4:26 pm     Reply with quote

Thankyou so much again guys, you're fab.
Things are working fine now, I was just getting a bit confused. I apologise that I was a little unspecific about certain things. All the best
T
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