oscilator mode in PICs

Status
Not open for further replies.

grekson

New Member
Hi,
This is extract from some book about PICs:

External oscillator in LP, XT or HS mode

The LP, XT and HS modes support the usage of internal oscillator for configuring clock source. The frequency of this source is determined by quartz crystal or ceramic resonators connected to the OSC1 and OSC2 pins. Depending on features of the component in use, select one of the following modes:

LP mode (Low Power) is used for low-frequency quartz crystal only. This mode is designed to drive only 32.768 kHz crystals usually embedded in quartz watches. It is easy to recognize them by small size and specific cylindrical shape. The current consumption is the least of the three modes;

XT mode is used for intermediate-frequency quartz crystals up to 8 MHz. The current consumption is the medium of the three modes ;and

HS mode (High Speed) is used for high-frequency quartz crystals over 8 MHz. The current consumption is the highest of the three modes.



Author talks about three different modes of EXTERNAL oscilator, but then he says that LP, XT and HS modes support the usage of INTERNAL OSCILATOR. This statement is a contadictive for me and I don't know if this is internal or external mode.
 
Last edited:
The oscillator is internal, but the crystal or timing components are external - otherwise how would you change them?.

A true external oscillator doesn't use the internal oscillator, but feeds directly in on a single pin.
 
I know what is "true" external oscilator.
I read this chapter in the book.
But still don't understand what has internal oscilator to do when we use external oscilator in LP, XT or HS mode. If external quarc crystal, cheramic resonator or resistor-capacitor gives us frequeny why do we need HF or LF INTOSC?
And also don't undestrand this diagram where we have external oscilator inside the chip.


I understand internal oscilator as where you don't need to connect anything to OSC1,2 pins.
 
Last edited:
I understand internal oscilator as where you don't need to connect anything to OSC1,2 pins.

Then you understand it - the internal oscillator requires no external components, the internal 'external' oscillator requires external components to work, and an external oscillator has the entire oscillator external and feeds in on a single pin.

It's only become confusing since they introduce componentless internal oscillators.
 
Then if we can use 8MHz internal oscilator (16F8xx) with no external components, than why most diagrams have external quarc chrystal? I understand that max frequency with HFINTOSC is 8MHz and if you want to use max permitted freq (20MHz for 16F887) you must use 20MHz external oscilator, but most diagrams have 8MHz external quarc chrystal.

As manual for my dev board stated, you choose osilator mode prior flasing the code to the MCU.
You do that in PICflash aplication, where you can choose osilator mode


But how do you set IRCF2-0 bits in OSCCON register that determine the clock signal (1,1,1 for example is 8MHz; 1,1,0 is 4MHz; 1,0,1 is 2MHz and so on)?
I thought you do that is compiler aplication (I use mikroPascal), where you set the clock that is by default 8MHz. But I can write any number even 100. And I noticed that program was excetuted faster when I lowered the number. When I set clock to be 0.1 leds was blinking faster than when I set clock to be 8???


Also strange to me is that leds is still blinking if I remove quarc crystal (with two jumpers) and oscilator mode is set to HSOSC. It seems that whatever I choose for osilator mode leds are still blinking with the same speed.
 
Last edited:
You use an external crystal for many reasons, the most important been that it's FAR, FAR more accurate and stable - you also have a far wider range of available frequencies.
 
Can you maybe also help about setting the freq and oscilator mode using above applications?
I know that you enable INTOSCIO flag for ext oscilator (both OSC pins are digital I/O), and that you set freq in compiler. You can also set OSCCON register in the code - values can be change durring program execution?

But what I don't understand is why PIC works faster when I set lower freq and why it is still working if flag for external oscilator is set, but there is nothing connected to OSC1,2 pins.
 
LP or HS is for ext xtals, which should also have 2 caps. Those are 2-wire because a driving pin must pulse the crystal to make it oscillate.
XT is for an external oscillator which takes in 5v and has a frequency output to a single PIC input pin. It's got its own driver. There is no way to put an external osc into SLEEP mode to save power. There IS a way to turn on the OSC2 output pin in this mode, but it's only if you have an unusual need on the board to do so. The oscillator doesn't use it, neither does the PIC.
Internal oscillator is free of external components. xtals are expensive and big! SMD xtals are almost as big as as the leaded versions and absolutely huge on a compact design where we SMD everything else. However, as Nigel stated, they're not very accurate. They vary with temp. But many (most, even) apps won't be affected if the timing is too fast or too slow by even a few %. This could theoretically make it unreliable if you accidentally exceed the absolute speed rating of the device or simply exceed the rating for the voltage you have available.

Many modern PICs have PLLs and thus the actual instruction speed can be separate from the xtal/ext osc/internal osc speed. Some devices only have a 4x multiplier. Others have a variety of scaling multipliers and dividers which can achieve a wide range of instruction freq from any oscillator.

I don't like third-party books myself. I recommend reading up on Microchip's own documentation- Microchip is pretty strong on documentation. They're very specific on what these oscillator settings mean.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…