cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496 RTC Timeout Outside a Building, OK Inside a Building

jerrybarber
Associate II

Hi,

I'm designing a board for weather observations and having a problem with the RTC timing out.

I'm using a TCXO as the input for the RTC on LSE.  The particular TCXO is ECS-327TXO-2012-33-TR.

Here is the weird thing.  If the board is inside a building, my house in this case, all is good, the RTC starts up no problem.   However, if the board is outside (it's a weather instrument so it will operate outside on battery power), the RTC fails to start up, with a timeout inside RTC_EnterInitMode.

If I run the RTC on LSI then all is fine, but I need more accuracy, thus the TCXO.

Below are details on the setup.  If any further information is required let me know.

Any help would be greatly appreciated!  This one really has me stumped.

Jerry

The circuit diagram for the TCXO is:

jerrybarber_0-1715185642531.png

Where XRTC-IN is connected to pin 3 (PC14-OSC32-IN) of a STM32L496RGT3.

Below is SystemClock_Config:

 

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct = {0};

RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 

/** Configure the main internal regulator output voltage

*/

if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)

{

while (true) {}

}

 

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.LSEState = RCC_LSE_BYPASS;

RCC_OscInitStruct.LSIState = RCC_LSI_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 1;

RCC_OscInitStruct.PLL.PLLN = 8;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;

RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;

 

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

while (true) {}

}

 

// RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

 

if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)

{

/* Initialization Error */

while(1);

}

}

And this is the RTC initialization:

 

/** Initialize RTC Only

*/

rtcHandle.Instance = RTC;

rtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;

rtcHandle.Init.AsynchPrediv = 127;

rtcHandle.Init.SynchPrediv = 255;

rtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;

 

rtcHandle.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;

rtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

rtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;

if (HAL_RTC_Init(&rtcHandle) != HAL_OK)

{

return false;

}

return true;

Below is HAL_RTC_MspInit:

void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) {

RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

if(hrtc->Instance==RTC) {

// Initializes the peripherals clock

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;

PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {

while (true) {}

}

/* Peripheral clock enable */

__HAL_RCC_RTC_ENABLE();

}

}

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

try : enable -> hi , connected to VDD.

Maybe the internal pullup is very high impedance, so even some moisture is enough to stop it working. 

+

ds of other ECS-327 series shows :

AScha3_1-1715197114027.png

So : better enable -> VDD .

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

7 REPLIES 7
Andrew Neil
Evangelist III

Is the TCXO starting OK ?

 

Please use this button to properly post source code:

AndrewNeil_0-1715188138812.png

 

 

Peter BENSCH
ST Employee

What about the pin ENABLE of the TCXO?

It wants to see a clear high level to make the TCXO work.

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Andrew, thanks for the hint on posting source code.

I'll check to see if it starts outside, I have to take part of my lab outside to determine if the TXCO is running.  It is running inside.

Jerry

Hello Peter,

As per the TCXO data sheet, if the enable is left open it should be enabled.

jerrybarber_0-1715195386337.png

 

Hi,

try : enable -> hi , connected to VDD.

Maybe the internal pullup is very high impedance, so even some moisture is enough to stop it working. 

+

ds of other ECS-327 series shows :

AScha3_1-1715197114027.png

So : better enable -> VDD .

 

If you feel a post has answered your question, please click "Accept as Solution".

Hi All,

Thanks for all your suggestions, they are very helpful.

Despite the fact that the datasheet says you can leave the enable pin open the problem was that is was left open.  Tying it to VDD seems to have solved the problem.

I appreciate the help.

Jerry

 

Weather can be very unkind to open pins.  Just wait for some serious ionization from a nearby lightning strike.