cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7508 change RTC after initialization

DElli.1
Associate III

I believe I am doing something wrong. I read that to re-write to the RTC I will need to:

1. Write ‘0xCA’ into the RTC_WPR register.

2. Write ‘0x53’ into the RTC_WPR register

I found a function in the RTC file that is:

#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__)       \

            do{                    \

              (__HANDLE__)->Instance->WPR = 0xCAU;  \

              (__HANDLE__)->Instance->WPR = 0x53U;  \

             } while(0U)

So I called that function like so:

__HAL_RTC_WRITEPROTECTION_DISABLE(&hrtc);

RTC_TimeTypeDef sTime = {0};

 RTC_DateTypeDef sDate = {0};

 sTime.Hours = hour;

 sTime.Minutes = minute;

 sTime.Seconds = 0x0;

 sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

 sTime.StoreOperation = RTC_STOREOPERATION_RESET;

 HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0x32F2);

 __HAL_RTC_WRITEPROTECTION_ENABLE(&hrtc);

And it simply does not work. Obviously I am doing something wrong, but I am not experienced enough to know where my error lies.

Help would be appreciated thank you.

1 REPLY 1

And which function is supposed to actually write to RTC->DR and RTC->TR?

JW