STM32 and external active oscillator - Page 1
Forum section: electronics / general

author: Koen
author_rank: Frequent Contributor
timestamp: March 12, 2015, 12:58:02 am
content: Hello,I'm having a terrible time trying to connect an STM32F4 High Speed External (HSE) clock to an external active oscillator (TCXO in this case). The documentation regarding this is tiny, I can't find an example schematic and my knowledge of oscillators is non-existent.Problem :I have seen no example whatsoever and an example schematic would be incredibly helpful.STM32 software won't toggle the HSE ready flag when HSE is configured in bypass mode (to be used with external oscillators). Guess it can't pick up the oscillation.Is the TCXO 0.8Vpp sine wave maybe too low to be noticed by the STM32 ? How could I raise it ?Connections :STM32 is well connected and works fine with its internal high speed oscillator.TCXO-VCC is bypassed to TCXO-GND with a 100nF capacitor.STM32 OSC_In is connected to TCXO-Out with a serie 10nF capacitor.STM32 OSC_Out is floating.Voltmeter reads 0.6V on TCXO-Out and 0.04V after the 10nF capacitor in serie.The TCXO is a Pericom WT325 :25Mhz.2.8Vin +-5% supplied with 2.9V.Outputs a clipped sine wave at 0.8Vpp.https://www.pericom.com/assets/Datasheets/WT325-Rev-06.pdfThe STM32 is a STM32F427VG :Supplied with 2.9V.Accepts 1-50Mhz external active oscillators.Accepts sine wave on OSC_In.OSC_In input high is 0.7V to VCC.OSC_In input low is VSS to 0.3V.http://www.st.com/web/en/resource/technical/document/datasheet/DM00071990.pdf"6.3.9 External clock source characteristics" page 116Thank you very much ! I've been on this for a week and haven't made any progress.

author: dannyf
author_rank: Super Contributor
timestamp: March 12, 2015, 01:05:54 am
content: QuoteYou probably want to understand the nature of an oscillator and your meter's readings.

author: Koen
author_rank: Frequent Contributor
timestamp: March 12, 2015, 01:44:41 am
content: It's to show the TCXO isn't dead and the capacitor blocks DC correctly. I'm learning and can't own an oscilloscope or frequency counter. Reading and respecting schematics and datasheets worked fine for all my previous endeavors but this time, I can't find any.

author: edavid
author_rank: Super Contributor
timestamp: March 12, 2015, 01:49:27 am
content: You misread the STM32 datasheet. The OSC_IN thresholds are 0.3VDDand 0.7VDD, so you need at least 1.2VPPfrom the oscillator (that's if you get the biasing just right). You should pick a different oscillator with CMOS level output.

author: Koen
author_rank: Frequent Contributor
timestamp: March 12, 2015, 02:42:17 am
content: Ho so it is low from 0V to (0.3timesVDD) 0.9V and high from (0.7timesVDD) 2.1V to VDD ! Thank you !

author: gxti
author_rank: Frequent Contributor
timestamp: March 12, 2015, 05:19:15 am
content: (posting here instead of replying to PM so it's searchable)You have to center it in the middle of where the schmitt trigger input is sensitive so that you get a nice 50% duty cycle. You need a DC blocking capacitor so you can center the signal where you want. Then you can either bias it with a resistor divider, or you can make use of the crystal oscillator circuit built into the microcontroller to center it through negative feedback. Internally it's basically just an inverter. The 10K resistor between OSC_IN and OSC_OUT acts as a RC filter for the inverted signal and keeps the capacitor biased in the middle. If the bias drifts too high then the OSC_OUT pin will spend more time low and bring the bias down, and vice versa.Either approach works but you have to do something -- you can't just stick a capacitor in series and nothing else, because nothing is determining where the DC level of that node is anymore.If you pick a TCXO with a suitable CMOS output then you don't need any of this, you can just wire it into OSC_IN and call it a day. I like this circuit because even if it's not strictly needed it still works, and it means you can swap in a different part later if you need to. This is also why there are two resistors on the TCXO's "EN" pin -- some models use it for voltage frequency control, and I can stuff parts as needed at assembly time. C6 is almost certainly not needed though.

author: Koen
author_rank: Frequent Contributor
timestamp: March 12, 2015, 05:46:28 am
content: Thank you ! Did you choose the 10K value by visualizing the wave on an oscilloscope ?I tried your circuit earlier with10K,10nFand the passive oscillator circuit on. The software was waiting for HSERDY. I re-readTaitien notepage 4 and tried1nFand365K. Now the HSERDY and PLLRDY are toggled and the software continues. Yet I don't have any means of verifying the PLL frequency right now.I tried it toowithout the external feedback resistor (your R10)and it worked. The STM32F427 datasheet linked above page 118 shows an"RF" resistorbetween OSC_IN and OSC_Out of200k.

author: gxti
author_rank: Frequent Contributor
timestamp: March 12, 2015, 05:53:10 pm
content: Make sure RCC_CR_HSEBYP isnotset -- you need the oscillator to be running, not in "external bypass" mode. Probe OSC_OUT with an oscilloscope and make sure you see something coming back out. Other than that, I don't know. 10K or 100K or 1M shouldn't make a difference -- I used that value because I was already using it elsewhere. The -3dB knee of this filter is orders of magnitude below the oscillation frequency, so it should work just fine. Using a bigger capacitor and/or resistor will push it even further down which is good.I wouldn't leave out the resistor. I'm not sure why the appnote recommends that configuration, because the only thing determining the DC bias would be leakage currents. It might work on the bench but not in the field, or stop working from one production run to the next. It also would not produce a 50% duty cycle which can potentially cause problems.If you can't get it to work using the STM32's oscillator then use an external inverter as shown on page 3 of the appnote. I recommend an unbuffered inverterwithouta schmitt trigger input; if you've only got 0.8Vpp that can be less than the hysteresis of some schmitt trigger inputs and in theory won't trigger at all. I've used 74LVC2GU04 for this in the past.To validate output frequency, use the MCO pin. You can set it to output SYSCLK to directly measure the CPU clock frequency. Even though outputs are too slew-limited to output a clean square wave at STM32F4's max frequency, you'll still see enough of a wave to validate with an oscilloscope or frequency counter.

author: Jeroen3
author_rank: Super Contributor
timestamp: March 12, 2015, 07:51:17 pm
content: If you do not have a oscilloscope you can count the number of ticks using the watchdog interrupt, or RTC. Those are in a different clock domain. Don't rely on the accuracy of the numbers. Use the LSI if you can.

author: westfw
author_rank: Super Contributor
timestamp: March 13, 2015, 08:42:34 am
content: QuoteI'd normally expect a microcontroller "external oscillator" input to require logic-level swings, and probably want nice square waves.(that's normally what I'd expect an oscillator module to provide, as well. One that provides 0.8v sine output seems aimed at some other purpose?)

author: Jeroen3
author_rank: Super Contributor
timestamp: March 13, 2015, 09:43:05 am
content: High frequency square waves contain a lot more frequency components than a sine. This can cause trouble with emc emissions.

author: gxti
author_rank: Frequent Contributor
timestamp: March 13, 2015, 01:59:17 pm
content: Quote from: westfw on March 13, 2015, 08:42:34 amI don't know why, but most of the TCXOs I looked at for my project were of this type. There are CMOS output types available but the least expensive and most widely available ones were clipped sine wave so I designed a circuit that was as flexible as possible.In practice the circuit I posted earlier works well, but it's marginal in terms of specs from the STM32 datasheet for schmitt trigger hysteresis vs the Vpp of the oscillator. I'd sleep better using an unbuffered input that would be acting as a limiter.

author: Koen
author_rank: Frequent Contributor
timestamp: March 14, 2015, 05:27:07 am
content: Hello,thank you all for your answers. A few bug fixes later and everything works great. This oscillator replaces two passive crystals and if the STM32 has nearly no documentation whatsoever, the other chip had recommended parts and a small schematic so I went with one of the recommended parts. Aside from that, I read that clipped sine wave oscillators could fit in a smaller form, consume less and be less of a risk EMI-wise. I, of course, don't have a clue about it.This is obviously another weird question butcould a VC-TCXO be used without voltage control? My usual distributor has a similar VC-TCXOhalf cheaperthan this TCXO. Would it preferrably be possible to tie the voltage control pin to VSS/VCC or to leave it floating ? The datasheet mentions :"AFC characteristics : ±9.0×10?6 to ±15.0×10?6/+1.5V±1V *2"VSS/VCC would be out of this 1.5±1V control range. I could also tie it to a 1.5V voltage divider but it's less easy as it is.Thank you very much !

author: dannyf
author_rank: Super Contributor
timestamp: March 14, 2015, 09:56:34 pm
content: QuoteYes.

author: Koen
author_rank: Frequent Contributor
timestamp: January 04, 2016, 11:32:58 am
content: Hello,Quote from: Jeroen3 on March 13, 2015, 09:43:05 amI would have a question about this and the correct placement of the TCXO output DC blocking capacitor.Apparently, two of my chips transform the clipped sine wave in square wave by themselves. If the distance between TCXO output and these chips inputs is 50mm, is it more advisable to place the capacitor near the TCXO output or near the chips XO input ?I imagine having the longest part of the trace as 0.8Vpp clipped sine wave is better than 2.8Vpp square wave ?Thank you !