Author Topic: Why do microcontrollerS have two oscillator pins?  (Read 11624 times)

0 Members and 1 Guest are viewing this topic.

Offline charlespaxTopic starter

  • Regular Contributor
  • *
  • Posts: 191
  • Country: us
    • Pax Instruments
Why do microcontrollerS have two oscillator pins?
« on: May 19, 2016, 09:51:43 pm »
Over in another thread we are working with an STM32F103 ARM microcontroller. To save PCB space I would like to use a MEMS oscillator chip (ASDM1 16 MHz), which is super tiny.

On the STM32F103 there is OSC_IN and OSC_OUT. I believe that OSC_IN is where the microcontroller reads the clock source, but I'm not entirely certain what OSC_OUT does. My best guess is that it goes HIGH to enable the external oscillator and LOW to disable it. Is this true? I could not find detailed information in the datasheet.

The ASDM1 has connections for power, ground, output (OUT), and tristate input (TRI). Connecting TRI to a logic high voltage or leaving it disconnected will enable OUT. Connecting TRI to GND disables output.



If what I believe about OSC_OUT is true, I should be able to connect OSC_OUT to TRI to allow the MCU to enable/disable the MEMS oscillator. Am I understanding this right?

If you'd like to see the full schematic, checkout the files on Github, see the other thread, or click the image below.

« Last Edit: May 19, 2016, 09:54:05 pm by charlespax »
 

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 7990
  • Country: gb
Re: Why do microcontrollerS have two oscillator pins?
« Reply #1 on: May 19, 2016, 09:58:32 pm »
It is used to drive a crystal into oscillation.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Why do microcontrollerS have two oscillator pins?
« Reply #2 on: May 19, 2016, 10:05:45 pm »
On the STM32F103 there is OSC_IN and OSC_OUT. I believe that OSC_IN is where the microcontroller reads the clock source, but I'm not entirely certain what OSC_OUT does. My best guess is that it goes HIGH to enable the external oscillator and LOW to disable it. Is this true? I could not find detailed information in the datasheet.

You have it in the reference manual, p. 125

If using external clock (aka not crystal/resonator):
"The external clock signal (square, sinus or triangle) with ~50% duty cycle has to drive the OSC_IN pin while the OSC_OUT pin should be left hi-Z."

If using HSE crystal/resonator then the crystal goes between the two OSC pins.

Not sure why is it called like that, I think it has to do with the topology of the oscillator, perhaps it is possible to measure the oscillator signal on the OSC_OUT pin or it is the pin used to drive the crystal.




 
The following users thanked this post: charlespax

Offline charlespaxTopic starter

  • Regular Contributor
  • *
  • Posts: 191
  • Country: us
    • Pax Instruments
Re: Why do microcontrollerS have two oscillator pins?
« Reply #3 on: May 19, 2016, 10:18:01 pm »
You have it in the reference manual, p. 125

If using external clock (aka not crystal/resonator):
"The external clock signal (square, sinus or triangle) with ~50% duty cycle has to drive the OSC_IN pin while the OSC_OUT pin should be left hi-Z."

If using HSE crystal/resonator then the crystal goes between the two OSC pins.

Not sure why is it called like that, I think it has to do with the topology of the oscillator, perhaps it is possible to measure the oscillator signal on the OSC_OUT pin or it is the pin used to drive the crystal.

Thank you :-+  I've been using the summary datasheet when I should have been using the full reference manual. The document I link to has this diagram:


This really clears things up. I owe you one  8)
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21606
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Why do microcontrollerS have two oscillator pins?
« Reply #4 on: May 19, 2016, 11:05:23 pm »
Usually, OSC_OUT is a CMOS pin like any other, but unlike any other, it has an unusually weak (and programmable) output drive strength, and analog feedback to bias it near VDD/2.

This allows it to drive a minimal AC voltage into the crystal, which typically has an impedance on the order of ~100 ohms, or ~1.5kohms, or ~100kohms (depending on series vs. parallel vs. tuning fork crystal styles).

By the way, the loading capacitors' reactance is always on the order of the crystal's ESR.  For example, a 20MHz, 100 ohm crystal might specify 18pF loading, which means you need two 36pF capacitors, one to ground on either side (as seen by the crystal, they act in series, hence 36/2 = 18pF loading).  18pF is 442 ohms at 20MHz, within a factor of 4.4.  (Note that actual loading capacitor *components* are smaller still, because the pins have capacitance too, which act in parallel with them.  This should be documented somewhere in the IC datasheet.  Just subtract it out from each capacitor, then use the result for the physical components, give or take maybe 10 or 20%.)

If it were a full-strength CMOS output, notice the capacitor wouldn't matter, because it would always be pushed around by the much stronger pin.  This is almost never done.  In fact, though it's rarely documented as such -- this is strongly hinted at by the ICs that require an external series resistor (usually around, guess what, 1.5kohms!) from OSC_OUT to the crystal.

That is, if the IC does not indicate an external resistor, then it has a controlled (weak) pin drive output.  If it does require an external resistor, then it is probably a regular CMOS output pin, and can be used and shared as any CMOS clock output pin.  (But test it, first. It's probably not documented as such.)

In any case, the other side of the crystal (OSC_IN) couples to an analog biased Schmitt trigger, which drives the OSC_OUT pin (at whatever drive strength it's designed/configured for).  The sensitivity is usually quite good (~0.1V?), so little power is required to drive the crystal, keeping efficiency good.

Tim
« Last Edit: May 19, 2016, 11:09:50 pm by T3sl4co1l »
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: helius

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2317
  • Country: au
Re: Why do microcontrollerS have two oscillator pins?
« Reply #5 on: May 20, 2016, 12:11:07 am »
If it were a full-strength CMOS output, notice the capacitor wouldn't matter, because it would always be pushed around by the much stronger pin.

Woah. I always wondered why the capacitor wasn't monstered by the XTAL out pin; and I always wondered why my silly attempt at getting a crystal to sing with a 1M resistor+NOT gate didn't work out (I was a lot younger at the time, didn't pursue the issue). I believe I have learned the answer to both these issues now...
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: Why do microcontrollerS have two oscillator pins?
« Reply #6 on: May 20, 2016, 05:19:09 am »
Its interesting to see someone consider a MEMS oscillator for a basic MCU design. The idea of these things is very appealing, as crystals are now one of the major causes of failure in well designed electronics. However, people have really struggled to get the cost performance balance right, and there don't seem to be many people left trying right now.
 

Offline Daniyal

  • Contributor
  • Posts: 18
Re: Why do microcontrollerS have two oscillator pins?
« Reply #7 on: May 20, 2016, 06:03:43 am »
Crystals will not oscillator on its own by simply connecting one pin to the OSC_IN pin, there is an inverter inside of the MCU and it acts like an amplifier in feedback loop which energise the crystal thus it can oscillate at the right frequency.
whereas oscillators will have this inverter inside of the package, it just needs power and ground it will output the desired frequency.

If you want to understand why this is the case read "AN2867 Oscillator design guide for ST microcontroller".
« Last Edit: May 20, 2016, 06:05:34 am by Daniyal »
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Why do microcontrollerS have two oscillator pins?
« Reply #8 on: May 20, 2016, 05:10:03 pm »
There we have a complete application note describing how to calculate the crystal oscillators properly:

http://www.ic-contract.ru/images/stm_files/stm8s/AN2867_Application_note.pdf

 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Why do microcontrollerS have two oscillator pins?
« Reply #9 on: May 20, 2016, 07:13:55 pm »
Thank you :-+  I've been using the summary datasheet when I should have been using the full reference manual. The document I link to has this diagram:


Yup, that's the diagram I was referring to.

This really clears things up. I owe you one  8)

Welcome.

Its interesting to see someone consider a MEMS oscillator for a basic MCU design. The idea of these things is very appealing, as crystals are now one of the major causes of failure in well designed electronics. However, people have really struggled to get the cost performance balance right, and there don't seem to be many people left trying right now.

Hmm, crystals being a major cause of failure? Do you have some more info on that? I have seen a lot of failed electronics and it was pretty much always due to the usual suspects - dead/cheap capacitors and blown transistors (or anything semiconductor). The remaining component types rank pretty low on the list - occasional smoked resistor or a shorted winding in something (trafo, motor, etc.). Never seen a failure caused by a crystal in modern gear. Even ancient 30+ years old crystals in old equipment are most likely going to be fine and work like new.
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 3632
  • Country: us
Re: Why do microcontrollerS have two oscillator pins?
« Reply #10 on: May 20, 2016, 08:21:50 pm »
Hmm, crystals being a major cause of failure? Do you have some more info on that? I have seen a lot of failed electronics and it was pretty much always due to the usual suspects - dead/cheap capacitors and blown transistors (or anything semiconductor). The remaining component types rank pretty low on the list - occasional smoked resistor or a shorted winding in something (trafo, motor, etc.). Never seen a failure caused by a crystal in modern gear. Even ancient 30+ years old crystals in old equipment are most likely going to be fine and work like new.
Crystals are especially sensitive to vibration (as they are highly stressed, brittle objects), and the ones with greater vibration tolerance are expensive. N.B. "in well designed electronics": those other failures can be anticipated and higher safety margins specified, but it's harder to do for crystals.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4391
  • Country: dk
Re: Why do microcontrollerS have two oscillator pins?
« Reply #11 on: May 20, 2016, 08:37:08 pm »
Hmm, crystals being a major cause of failure? Do you have some more info on that? I have seen a lot of failed electronics and it was pretty much always due to the usual suspects - dead/cheap capacitors and blown transistors (or anything semiconductor). The remaining component types rank pretty low on the list - occasional smoked resistor or a shorted winding in something (trafo, motor, etc.). Never seen a failure caused by a crystal in modern gear. Even ancient 30+ years old crystals in old equipment are most likely going to be fine and work like new.
Crystals are especially sensitive to vibration (as they are highly stressed, brittle objects), and the ones with greater vibration tolerance are expensive. N.B. "in well designed electronics": those other failures can be anticipated and higher safety margins specified, but it's harder to do for crystals.

and most of the failures will probably never bee seen my anyone but the manufacturer, i.e. a failed xtal means the device fails final test and gets thrown in the naughty pile


 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Why do microcontrollerS have two oscillator pins?
« Reply #12 on: May 21, 2016, 12:30:57 am »
Be careful about interfacing to osc pins. Some UPs have complex bias arrangements
on input side that if not properly handled will create a noise margin problem when used
as a digital input. I have seen datasheets that do not discuss this, but the problem is
present. Contact FAE at vendor for resolution of what the pins actually model like.

Aslo in typical osc circuits there is an R that sets xtal drive, limits power applied, while
also providing phase shift contribution to network. Not a simple tradeoff.

This ap note pretty good http://cache.freescale.com/files/microcontrollers/doc/app_note/AN1706.pdf

http://electronicdesign.com/analog/fundamentals-crystal-oscillator-design



Regards, Dana.
« Last Edit: May 21, 2016, 12:45:36 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: Why do microcontrollerS have two oscillator pins?
« Reply #13 on: May 21, 2016, 10:29:46 am »
Its interesting to see someone consider a MEMS oscillator for a basic MCU design. The idea of these things is very appealing, as crystals are now one of the major causes of failure in well designed electronics. However, people have really struggled to get the cost performance balance right, and there don't seem to be many people left trying right now.

Hmm, crystals being a major cause of failure? Do you have some more info on that? I have seen a lot of failed electronics and it was pretty much always due to the usual suspects - dead/cheap capacitors and blown transistors (or anything semiconductor). The remaining component types rank pretty low on the list - occasional smoked resistor or a shorted winding in something (trafo, motor, etc.). Never seen a failure caused by a crystal in modern gear. Even ancient 30+ years old crystals in old equipment are most likely going to be fine and work like new.
Notice I said well designed electronics. If you have capacitors failing in significant numbers within the expected life of the equipment its not well designed. If transistors are failing due to thermal or electrical stress the equipment is not well designed. In well designed equipment crystals are the cause of a substantial number of failures.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Why do microcontrollerS have two oscillator pins?
« Reply #14 on: May 21, 2016, 03:00:31 pm »
Crystals are especially sensitive to vibration (as they are highly stressed, brittle objects), and the ones with greater vibration tolerance are expensive. N.B. "in well designed electronics": those other failures can be anticipated and higher safety margins specified, but it's harder to do for crystals.

And how is that different for MEMS?  :-// These are explicitly mechanical - dropping something like a MEMS accelerometer on the floor can destroy it.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Why do microcontrollerS have two oscillator pins?
« Reply #15 on: May 21, 2016, 03:07:03 pm »
Notice I said well designed electronics. If you have capacitors failing in significant numbers within the expected life of the equipment its not well designed. If transistors are failing due to thermal or electrical stress the equipment is not well designed. In well designed equipment crystals are the cause of a substantial number of failures.

Then you should probably define what you mean by "well designed electronics". If it is obscure big buck lab gear assembled by naked virgins in single quantities, sure. I don't have experience with avionics and space rated stuff, so can't speak about that.

Otherwise for "normal" electronics those capacitors or semiconductors are much more likely to give up the ghost than anything else, even in well designed equipment. Caps in switching power supplies are essentially a planned obsolescence element - they will fail, it is not a question of if but when. The semiconductors could blow up for tons of reasons too - e.g. a power surge, user stupidity, hidden manufacturing fault, whatever. Poor design is not the only reason why electronics fails. Sometimes it is just not economical or possible to protect the gear against all possible risks (and then idiots tend to be very creative and resourceful).

 

Online coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: Why do microcontrollerS have two oscillator pins?
« Reply #16 on: May 22, 2016, 08:36:49 am »
Notice I said well designed electronics. If you have capacitors failing in significant numbers within the expected life of the equipment its not well designed. If transistors are failing due to thermal or electrical stress the equipment is not well designed. In well designed equipment crystals are the cause of a substantial number of failures.

Then you should probably define what you mean by "well designed electronics". If it is obscure big buck lab gear assembled by naked virgins in single quantities, sure. I don't have experience with avionics and space rated stuff, so can't speak about that.

Otherwise for "normal" electronics those capacitors or semiconductors are much more likely to give up the ghost than anything else, even in well designed equipment. Caps in switching power supplies are essentially a planned obsolescence element - they will fail, it is not a question of if but when. The semiconductors could blow up for tons of reasons too - e.g. a power surge, user stupidity, hidden manufacturing fault, whatever. Poor design is not the only reason why electronics fails. Sometimes it is just not economical or possible to protect the gear against all possible risks (and then idiots tend to be very creative and resourceful).
Normal electronics includes things like your water meter or electricity meter, made at low cost in a very competitive market. It is expected to run for 10 to 20 years (depending on the utility) with a low failure rate. Early failures due to inappropriately chosen capacitors can result in big penalties for the maker, so they generally avoid them. In these types of application crystals are now one of the major causes of early failure.
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 8605
  • Country: gb
Re: Why do microcontrollerS have two oscillator pins?
« Reply #17 on: May 22, 2016, 08:55:19 am »
Crystals are especially sensitive to vibration (as they are highly stressed, brittle objects), and the ones with greater vibration tolerance are expensive. N.B. "in well designed electronics": those other failures can be anticipated and higher safety margins specified, but it's harder to do for crystals.

And how is that different for MEMS?  :-// These are explicitly mechanical - dropping something like a MEMS accelerometer on the floor can destroy it.
Not all mechanical devices are created equal. One of the key benefits promoted for MEMS resonator oscillators is their greater tolerance to mechanical abuse. It is far harder to disturb heir normal operation with vibration, and the level of mechanical stress needed to damage them is also far higher.

The characteristics of MEMS resonators are very different from crystals. For example, they have horrible temperature coefficients compared to crystals, or even ceramic resonators. You will see some MEMS oscillators with a very good temperature coefficient, but that's because they have added an elaborate temperature measurement and correction scheme on the silicon.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf