AnsweredAssumed Answered

F767 Nucleo RTC drift

Question asked by macgeorge on Jan 15, 2017
Latest reply on Jan 19, 2017 by Steve Hageman

Hello,

I have been using the RTC of the Nucleo 144 F767 board with the onboard 32768kHz oscillator and I noticed that there is a large drift (~2 minute lag per day or ~1570ppm).

Based on the datasheet, the crystal drift is 200ppm. Moreover, the calibration registers can compensate for ±488ppm, so I have to finetune the clock using the synchronous and asynchronous prescalers.

I am wondering if I haven't initialized the registers correctly (key registers shown below) or if someone else has noticed a similar clock drift on Nucleo boards.

Thanks,
George

 

 

System Init

SCB_EnableICache();

SCB_EnableDCache();

__HAL_RCC_PWR_CLK_ENABLE();

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.HSIState = RCC_HSI_OFF;

RCC_OscInitStruct.LSEState = RCC_LSE_ON;

RCC_OscInitStruct.LSIState = RCC_LSI_OFF;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLM = 8;

RCC_OscInitStruct.PLL.PLLN = 432;

RCC_OscInitStruct.PLL.PLLP = 2;

RCC_OscInitStruct.PLL.PLLQ = 2;

HAL_RCC_OscConfig(&RCC_OscInitStruct);

 

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_DIV4;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);

 

HAL_PWREx_EnableOverDrive();

PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_USART3;

PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;

PeriphClkInitStruct.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;

HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);

 

RTC Prescalers

RTCHandle.Init.AsynchPrediv = 127;

RTCHandle.Init.SynchPrediv = 255;

Outcomes