cancel
Showing results for 
Search instead for 
Did you mean: 

I am using an STM32H743 user board with STMCubeIDE. I want to use the internal RTC calendar with the internal clock (LSI). Q: first power on clock start 17:20:00 then time is going. For example, when time is 17:20:50 suddenly I power off the

Abdelmalek BELLOULA
Associate III

MX_RTC_Init();

if (HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DRX) != 0X2233) {

printf(" Set Date and Time \r\n");

SetDateTime();

}

void SetDateTime(void) {

RTC_TimeTypeDef sTime = { 0 };

RTC_DateTypeDef sDate = { 0 };

/* USER CODE BEGIN Check_RTC_BKUP */

/* USER CODE END Check_RTC_BKUP */

/** Initialize RTC and set the Time and Date*/

sTime.Hours = 0x19;

sTime.Minutes = 0x45;

sTime.Seconds = 0x30;

sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

sTime.StoreOperation = RTC_STOREOPERATION_RESET;

if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) {

Error_Handler();

}

sDate.WeekDay = RTC_WEEKDAY_FRIDAY;

sDate.Month = RTC_MONTH_MARCH;

sDate.Date = 0x25;

sDate.Year = 0x22;

if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK) {

Error_Handler();

}

HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DRX, RTC_BKP_DATA);

}

1 ACCEPTED SOLUTION

Accepted Solutions

Then your LSE oscillator is probably not stable.

Read AN2867. Try on a "known good" board like Nucleo or Disco. Experiment with LSE drive level.

JW

View solution in original post

5 REPLIES 5

There is no question, but I'll try to guess: LSI is not in battery-backup domain, so it stops working when VDD is removed.

LSI is also very imprecise, see datasheet.

JW

Abdelmalek BELLOULA
Associate III

Thank you for the answer indeed I have a problem with the time display, it freezes as soon as I remove the power supply.

I started to test with LSE I have the same problem and also the fact that the display of seconds is not very stable (periodic)

Then your LSE oscillator is probably not stable.

Read AN2867. Try on a "known good" board like Nucleo or Disco. Experiment with LSE drive level.

JW

Abdelmalek BELLOULA
Associate III

Thanks for your help

Abdelmalek BELLOULA
Associate III

The problem is solved, it works very well, the problem comes from a fault in the oscillator at the level of the PC14-OSC32_IN and PC15-OSC32_OUT pins.

Thank you waclawek.jan for your orientation