2018-10-31 09:54 AM
I'm experiencing some problems with a project I have taken over.
The Processor is STM32F071RBT6TR and the problem concerns writing data to the RTC Backup Registers.
After a power on reset there is no problem writing to these registers, however after our unit is placed in Standby it appears that write access is disabled.
Standby is achieved using the following:
PWR_CR - Set PDDS bit (Powerdown Deep Sleep)
SCB_SCR - Set Sleep Deep Bit
Wait for Interrupt command
Write Access to the memory in question is performed by the following actions:
__HAL_RTC_WRITEPROTECTION_DISABLE(&hrtc);
uint32_t reg = HAL_RTCEx_BKUPRead(&hrtc, 0);
HAL_RTCEx_BKUPWrite(&hrtc, 0, (reg & ~0xFF) | (value & 0xFF));
__HAL_RTC_WRITEPROTECTION_ENABLE(&hrtc);
where value is the byte to be written.
I'm not sure the "__HAL_RTC_WRITEPROTECTION" disable and enable are needed here.
Regards Doug