cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 external oscillator tcxo

yada2
Associate II
Posted on March 02, 2015 at 01:34

Hello,

I would like to give external oscillators (TCXO, VCXO, etc) a try as HSE but can't find any diagram or documentation about it regarding STM32(F427).

Could you please help with these three questions :

  • OSC_IN connected to oscillator output, OSC_OUT left floating ?
  • Is adding the HSE_BYPASS flag to the HSE register during startup the only required software change ?
  • Can the oscillator start before the STM32 ? or should its startup be controlled by the STM32 ?

Thank you !

#tcxo #stm32 #stm32f4 #crystal
9 REPLIES 9
Posted on March 02, 2015 at 03:30

Yes, no connection of OSC_OUT is required, not sure it's usable as a GPIO (might be a stated fact, or errata, don't recall), and you should enable BYPASS so nothing is output via OSC_OUT

OSC_IN for a TCXO type source can be 1-50 MHz, yes you could enable it after the STM32 starts from HSI, most 4-pin TCXO's I'm aware of don't have an enable pin, while some VCXO/TCXO have a tuning/control pin.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yada2
Associate II
Posted on March 03, 2015 at 18:39

Thank you ! I etched a test board but the software blocks at the ''waiting PLLRDY'' loop. I had a terrible time finding STM32+XO documentation, schematic or recommended parts so wouldthere be a problem with a 26Mhz, clipped sine wave, 0.8Vpp VCTCXO with a 0.1nF bypass capacitor between XO-VCC and GND and a 1000pF DC-blocking capacitor between XO-OUTPUT and OSC_IN ? Am I missing any component ?

Simplified schematic :

http://i.imgur.com/KMXgSsO.jpg

Exact part datasheet :

http://www.ndk.com/cataloge/co12_NT3225SA_AFC_e1.pdf

Tracks on PCB areunder 8mm, connections are good. Line 539 in STM32CubeF4stm32f4xx_hal_rcc.c :

/* Configure the main PLL clock source, multiplication and division factors. */
__HAL_RCC_PLL_CONFIG(RCC_OscInitStruct->PLL.PLLSource,
RCC_OscInitStruct->PLL.PLLM,
RCC_OscInitStruct->PLL.PLLN,
RCC_OscInitStruct->PLL.PLLP,
RCC_OscInitStruct->PLL.PLLQ);
/* Enable the main PLL. */
__HAL_RCC_PLL_ENABLE();
/* Get Start Tick*/
tickstart = HAL_GetTick();
/* Wait till PLL is ready */
while
(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET)

Thank you very much !
Posted on March 03, 2015 at 19:18

But what PLL settings are you using?

PLL_M = 26

PLL_N = 336   (168 MHz *2)

PLL_P = 2;

You can also output internal clocks via the MCO pins. Would suggest you output HSE via PA8 and check with a scope.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yada2
Associate II
Posted on March 03, 2015 at 19:24

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 26;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig(&RCC_OscInitStruct);

Thank you !
yada2
Associate II
Posted on March 03, 2015 at 19:48

With ON instead of BYPASS, the software doesn't infinite loop waiting for PLLRDY.

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

Posted on March 03, 2015 at 19:49

Not a HAL guy, but in SPL we'd get the HSE out PA8 with

/* Output HSE clock on MCO1 pin(PA8) ****************************************/
/* Enable the GPIOA peripheral */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
/* Configure MCO1 pin(PA8) in alternate function */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* HSE clock selected to output on MCO1 pin(PA8)*/
RCC_MCO1Config(RCC_MCO1Source_HSE, RCC_MCO1Div_1);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
yada2
Associate II
Posted on March 03, 2015 at 20:25

I tried DSP V1.4 and the same problem arise : infinite loop waiting for RCC_CR_PLLRDY if BYPASS is set, no loop if BYPASS is not set.

I won't have access to an oscilloscope for a week (student) so I'm stuck here, sorry. Thank you for the help.
yada2
Associate II
Posted on March 09, 2015 at 08:16

Hello, I haven't had access to testing equipments yet but I'd like to understand the BYPASS flag better. With BYPASS set ''waiting PLLRDY'' loops, without it : SystemInit, TIM, USB, SDIO and FMC work fine.

If I understood it correctly, setting the BYPASS flag simply cancels the OSC_OUT output. But OSC_OUT is floating and thus shouldn't have any impact. Is there more to it ? Thank you !

I am not absolutely sure but I think I can explain why MCU and TCXO do not work together in BYPASS mode.

Your TCXO has output voltage 0.8V.

When BYPASS mode is used, OSC_IN is a digital input and it requires >0.7*VDD for high level and <0.3*VDD for low level signal. So, TCXO's output voltage is too low.

When BYPASS mode is off, an amplifier in MCU is activated (see diagram in datasheet) and 0.8 V on OSC_IN is enough.