Author Topic: STM32 and external active oscillator  (Read 16329 times)

0 Members and 1 Guest are viewing this topic.

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 527
STM32 and external active oscillator
« on: March 12, 2015, 12:58:02 am »
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 :
The STM32 is a STM32F427VG :

Thank you very much ! I've been on this for a week and haven't made any progress. :-[
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: STM32 and external active oscillator
« Reply #1 on: March 12, 2015, 01:05:54 am »
Quote
Voltmeter reads 0.6V on TCXO-Out and 0.04V after the 10nF capacitor in serie.

You probably want to understand the nature of an oscillator and your meter's readings.
================================
https://dannyelectronics.wordpress.com/
 

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 527
Re: STM32 and external active oscillator
« Reply #2 on: March 12, 2015, 01:44:41 am »
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.
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3012
  • Country: us
Re: STM32 and external active oscillator
« Reply #3 on: March 12, 2015, 01:49:27 am »
You misread the STM32 datasheet.  The OSC_IN thresholds are 0.3VDD and 0.7VDD, so you need at least 1.2VPP from the oscillator (that's if you get the biasing just right).  You should pick a different oscillator with CMOS level output.
 

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 527
Re: STM32 and external active oscillator
« Reply #4 on: March 12, 2015, 02:42:17 am »
Ho so it is low from 0V to (0.3 times VDD) 0.9V and high from (0.7 times VDD) 2.1V to VDD ! Thank you !
 

Offline gxti

  • Frequent Contributor
  • **
  • Posts: 507
  • Country: us
Re: STM32 and external active oscillator
« Reply #5 on: March 12, 2015, 05:19:15 am »
(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.
 

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 527
Re: STM32 and external active oscillator
« Reply #6 on: March 12, 2015, 05:46:28 am »
Thank you ! Did you choose the 10K value by visualizing the wave on an oscilloscope ?

I tried your circuit earlier with 10K, 10nF and the passive oscillator circuit on. The software was waiting for HSERDY. I re-read Taitien note page 4 and tried 1nF and 365K. 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 too without the external feedback resistor (your R10) and it worked. The STM32F427 datasheet linked above page 118 shows an "RF" resistor between OSC_IN and OSC_Out of 200k.
« Last Edit: March 12, 2015, 06:09:04 am by Koen »
 

Offline gxti

  • Frequent Contributor
  • **
  • Posts: 507
  • Country: us
Re: STM32 and external active oscillator
« Reply #7 on: March 12, 2015, 05:53:10 pm »
Make sure RCC_CR_HSEBYP is not set -- 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 inverter without a 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.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 3590
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32 and external active oscillator
« Reply #8 on: March 12, 2015, 07:51:17 pm »
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.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3304
  • Country: us
Re: STM32 and external active oscillator
« Reply #9 on: March 13, 2015, 08:42:34 am »
Quote
Outputs a clipped sine wave at 0.8Vpp.
I'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?)
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 3590
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32 and external active oscillator
« Reply #10 on: March 13, 2015, 09:43:05 am »
High frequency square waves contain a lot more frequency components than a sine. This can cause trouble with emc emissions.
 

Offline gxti

  • Frequent Contributor
  • **
  • Posts: 507
  • Country: us
Re: STM32 and external active oscillator
« Reply #11 on: March 13, 2015, 01:59:17 pm »
Quote
Outputs a clipped sine wave at 0.8Vpp.
I'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?)
I 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.
 

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 527
Re: STM32 and external active oscillator
« Reply #12 on: March 14, 2015, 05:27:07 am »
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 but could a VC-TCXO be used without voltage control? My usual distributor has a similar VC-TCXO half cheaper than 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 !
« Last Edit: March 14, 2015, 05:46:31 am by Koen »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: STM32 and external active oscillator
« Reply #13 on: March 14, 2015, 09:56:34 pm »
Quote
could a VC-TCXO be used without voltage control?

Yes.
================================
https://dannyelectronics.wordpress.com/
 

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 527
Re: STM32 and external active oscillator
« Reply #14 on: January 04, 2016, 11:32:58 am »
Hello,

High frequency square waves contain a lot more frequency components than a sine. This can cause trouble with emc emissions.

I 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 !
« Last Edit: January 04, 2016, 11:40:14 am by Koen »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf