2017-01-15 12:01 AM
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,
GeorgeSystem 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;
#nucleo-f767zi #f767-rtc2017-01-17 07:36 AM
Hello
Christidis.George
,You can perform a digital smooth calibration to compensate the RTC clock deviation
for the inaccuracy of crystal oscillators. This is mentioned in the
application note in the 'Digital smooth calibration' section.Also, you may review the
and RTC chapter in your for more clarification.Hope this helps you.
Regards
Imen
2017-01-17 12:01 PM
I had this problem once, it turned out that the EE didn't put the proper capacitors for the oscillator.
Different crystals specify the capacitor/resistors that they need to get their designed precision. Make sure the implementation matches the design.
A
2017-01-17 12:42 PM
Thanks for your response. The digital calibration does not apply for this case, since, as I wrote above it can manage a maximum drift of ±448ppm and I am observing a drift of 1570ppm. That's why I am obligated to use the synchronous and asynchronous prescalers (RTC->PRER).
Concerning the documentation you have indicated, since I am using a Nucleo board, board layout shouldn't be an issue, although based on the schematic, the capacitance is a bit different than the recommended one (maybe to compensate for the track capacitance as well).
Moreover, since the RTC is indeed operating, the rest of the initialization seems correct (except maybe the setup of the registers that select RTC timing). So my question was to inquire if someone else has seen similar drifts on the specific board.
Thanks,
George
2017-01-17 01:30 PM
Clocks have been perfected over hundreds of years.
The clients are really expecting an accurate time.
Can you update from the web periodically ?
Otherwise a stand alone RTC is necessary... Specified @ Max 2Minutes deviation per Year,
DS3231 IIC with internal Temperature Compensated Crystal without battery backed ram,
DS3232 IIC with internal Temperature Compensated Crystal with 236bytes ram,
DS3234 SPI with internal Temperature Compensated Crystal with 256bytes ram,
or less accurate DS3232M (4minutes per year drift) without crystal
2017-01-18 04:58 AM
Given the ds323x series has many of the same features as the stm32 rtc, how would you use the ds323x?
Would you set your stm32 rtc and periodically compare it to the ds323x, or would you turn off the stm32 rtc and use just the ds323x?
2017-01-18 05:28 AM
Hi,
I would update every hour.. if you are concerned, maybe every minute...
I actually, just use the DS3232SN product, I don't use the processor RTC at all.
basically only read it when I need to timestamp.
2017-01-19 07:26 AM
Hi George - I have had many problems from these 32kHz clocks over the years due to humidity - because of the very high impedance's involved they are very, very sensitive to even 'normal' atmospheric humidity.
One thing that I see on a lot of pre-made computer boards is a coating of 'RTV' over the crystal oscillator portion of the circuit to keep the humidity out.
One way to test if humidity is the problem is to put the board next to a heat lamp (or light bulb, etc) and heat it to 10 to 20 Deg C over ambient and to check if the problem goes away. Heating a board like this will drive the humidity right out of it.
If this heating fixes the problem then you know it is humidity.
Hope this helps.