Why RTC backup register write fails? (STM32F446)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-01-02 12:01 PM
(this is re-post because of the 'forums issue')
I have the following function to write a RTC backup register of 446ZCT:
All RTC initialization code is generated by CubeMX.
void put_backup_num(uint8_t num)
{ __HAL_RTC_WRITEPROTECTION_DISABLE(&hrtc); HAL_PWR_EnableBkUpAccess(); __HAL_RTC_WRITEPROTECTION_DISABLE(&hrtc);HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR18, num);
uint32_t d = HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR18);
if (num != (d & 0xFF) ) { printf('backup write failed!\n'); }}and read-back always fails. Read values are always 0.
What is missing?
Thanks,
Pavel
#stm32f446 #rtc-backupSolved! Go to Solution.
- Labels:
-
RTC
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-01-02 1:14 PM
Can you write to other RTC registers?
Is tamper set/active?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-01-02 1:14 PM
Can you write to other RTC registers?
Is tamper set/active?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-01-03 1:27 AM
Hi
pavel_a
,You find a ready to use example with STM32F446 underSTM32Cube_FW_F4_V1.0\Projects\STM32F446ZE-Nucleo\Examples\RTC\RTC_Tamper.
It helps you to review all configuration steps to write/read data to/from RTC Backup data registers.
You find more details about this example in the readme.txt file.
You may test this example. If it works as expected, then compare this implementation with CubeMX generated code. May be some API calls are missing in the code you added.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-01-03 4:32 AM
Thank you Jan and Amel.
It was the tamper thing. Some time ago I played with tamper and it somehow persisted even after several full erases of the chip. In the current init code, only RTC is initialized but not the tamper switch.
So I've added following lines from the example pointed by Amel after the RTC init code generated by cubemx:
HAL_RTCEx_DeactivateTamper(&hrtc, RTC_TAMPER_1);
__HAL_RTC_TAMPER_CLEAR_FLAG(&hrtc, RTC_FLAG_TAMP1F);Then backup regs become writable.
Regards,
-- pa
