News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Capacitor for 16Mhz oscillator on 18F25k22 chip

Started by Yves, Mar 29, 2022, 11:07 AM

Previous topic - Next topic

Yves

Hi all,

I can't find anymore on datasheet the suggested the two capacitors required for a crystal at 16Mhz on the 18F25K22 chip?
Many thanks,

Regards,

Yves
Yves



tumbleweed

QuoteI can't find anymore on datasheet the suggested the two capacitors required for a crystal at 16Mhz on the 18F25K22 chip?
That's because it depends more on the specs of the xtal you select than the K22.
See app note AN949 https://ww1.microchip.com/downloads/en/appnotes/00949a.pdf

You'll probably be ok with something in the 15pF range...

top204

#4
20 to 30 pF may pull the crystal off a little. They are more suitable for a crystal of 10 MHz or below.

I still remember finding the suitable capacitors for the Amicus18 board by creating a simple RTC with a timer interrupt, then leaving it on for a few days and seeing how far the oscillator had drifted over time, on a serial terminal that also had the computer's clock beside the interrupt RTC clock time's text. Then changing the capacitor values and doing the same test. :-) 11pF to 15pF were more suitable, but 15pF were less expensive at the time.

I have always advocated: "forget most of the laboratory based calculations and values, and perform real tests in the real world", wherever possible. Also, as has been stated above, the crystal itself comes into play because they have various internal capacitances themselves.

rick.curl

Look at the crystal spec sheet.  All crystals are designed to work with a specific capacitance- but one important thing to remember is that the crystal "sees" the two capacitors as if they were in series, so you will want to select capacitors that are slightly less than double the specified value. 18pF is a common value you will see on the spec sheets.  If that's the case, use a 30pF capacitor.
The reason I say to select a value slightly LESS than twice the values is that there will always be a bit of stray capacitance in your circuit, so this allows for it.

-Rick

Yves

Many thanks for your answers. I have placed on the board two 22pF on each side of the crystal(that was all I had in hand). Hopefully it will work.
Regards,

Yves
Yves

top204

#7
It will work Yves.

The only thing a slightly larger capacitor will do is pull the frequency off by a little. However, a large capacitance will stop the oscillator working and you will find that out straight away if your test program does not work. You cannot beat a flashing LED test program when first developing a microcontroller circuit. :-)

You can always use the internal 16MHz oscillator and enable the PLL, so it works at 64MHz without the external crystal. I tend to do this now because the internal oscillators and PLL are very good at keeping stability, even with high and low temperatures. I tested a few of the newer microcontrollers with a freezer spray and in a warm oven and they worked nicely.

It also makes two extra I/O pins available (RA6 and RA7).

trastikata

While on this topic - how reliable is the internal load resistor for PICs?

In the distant past I used to have troubles with some devices having problems starting up their oscillators and I made it a habit placing 1M load resistor across the crystals, regardless what the datasheet says and never had any issues since. 

Yves

Some suggestions I found they place slightly asymmetric values to insure a good start-up 
Yves

top204

Do not always believe what you read on the internet. :-)

PIC microcontrollers have come a long way in the years that they have been around, and a lot of the info on the internet is very much out of date, or... "Because something happened that a person did not quite understand, they did something they did not understand and it seemed to work, so it must be fact!!!!", when in fact it is not fact but old wives tales that get written down and copied/pasted, copied/pasted on and on.... as facts. LOL 

The oscillators on the microcontrollers for the past 10 or 12 years are very stable and I have never come across an oscillator that did not power up, and I have created many hundreds of designs with them, internal oscillators and external crystals and resonators etc... The very early PIC microcontrollers did sometimes have a problem with some crystals, so they sometimes needed a high value resistor across the OSC pins. But the newer types do not need it.

The same with the capacitors. They are there to help stop any ringing in the oscillator, and sometimes, the capacitance in the crystal alone is enough for them, because the PCB also has a capacitance.

david

Rick was absolutely right and the xtal load capacitance is specified by the xtal manufacturer to ensure the oscillator is on its calibrated frequency.  There are additional factors that come in to play.  The load capacitance dictates the actual xtal current.  If it's too low the oscillator may fail to start, would be high in frequency and display poor phase noise.  If too high the frequency will be lower than specified and the higher xtal current leads to premature aging.  Extreme overdrive leads to frequency jumps.
As Rick has indicated, the two load capacitors are effectively in series so a xtal specified for say a 15pF load (to set correct frequency and xtal current) would use a value of twice that (30pF) at input and output of the inverter, less a few pF for track and pin capacitance, hence 2pcs of 27pF.
The resistance used to self bias the inverter is not very critical and very little xtal current flows through it.  Generally the lower the frequency the higher the resistance so you will often find 10M resistors on 32.768kHz oscillators (with tuning fork resonators), 1M resistors on oscillators using up to about 16MHz xtal resonators and down to around 50k resistors for oscillators using 30MHz xtal resonators and up.
Most oscillators will run with no xtal load capacitance, working just with stray track and pin capacitance but apart from being high infrequency and very low in xtal current the input node of the inverter will be highly susceptible to noise from adjacent digital lines.  This may exhibit an even higher frequency dither due to random triggering of the input.

Cheers,
David