2018-08-08 07:29 AM
Is there something else that I am missing? I have followed the instructions in UM1884 and RM0394, but after writing to BKP0R, it still reads zero (even with NoErase).
0x40021058: 1006c401 1 RCC_APB1ENR1_PWREN
0x40007000: 00000300 1 PWR_CR1_DBP
0x40021090: 00008200 2 RCC_BDCR_RTCSEL
0x40021090: 00008200 1 RCC_BDCR_RTCEN
0x40002840: 000000a0 1 RTC_TAMPCR_TAMP3E
0x40002850: 00000000 0 RTC_BKP0R
HAL_PWR_EnableBkUpAccess()
__HAL_RCC_RTC_ENABLE()
0x40021058: 1006c401 1 RCC_APB1ENR1_PWREN
0x40007000: 00000300 1 PWR_CR1_DBP
0x40021090: 00008200 2 RCC_BDCR_RTCSEL
0x40021090: 00008200 1 RCC_BDCR_RTCEN
0x40002840: 000000a0 1 RTC_TAMPCR_TAMP3E
HAL_RTCEx_BKUPWrite(hrtc, 0, 0x12345678)
HAL_RTCEx_BKUPRead(hrtc, 0) = 0x0
0x40002850: 00000000 0 RTC_BKP0R
>
> md 0x40002800 0xd0
0x40002800: 08 08 00 00 01 21 00 00 00 00 00 00 27 88 00 00 .....!......'...
0x40002810: FF 00 7F 00 FF FF 00 00 00 00 00 00 00 00 00 00 ................
0x40002820: 00 00 00 00 00 00 00 00 C4 00 00 00 00 00 00 00 ................
0x40002830: 00 00 00 00 01 21 00 00 FD 00 00 00 00 00 00 00 .....!..........
0x40002840: A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> mw 0x40002850 0x1234
0x40002850: 00001234
> md 0x40002800 0xd0
0x40002800: 08 08 00 00 01 21 00 00 00 00 00 00 27 88 00 00 .....!......'...
0x40002810: FF 00 7F 00 FF FF 00 00 00 00 00 00 00 00 00 00 ................
0x40002820: 00 00 00 00 00 00 00 00 89 00 00 00 00 00 00 00 ................
0x40002830: 00 00 00 00 01 21 00 00 FD 00 00 00 00 00 00 00 .....!..........
0x40002840: A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
>
UM1884
54.2.3 Backup Domain Access
After reset, the backup domain (RTC registers, RTC backup data registers and backup
SRAM) is protected against possible unwanted write accesses.
To enable access to the RTC Domain and RTC registers, proceed as follows:
1. Call the function HAL_RCCEx_PeriphCLKConfig with RCC_PERIPHCLK_RTC for
PeriphClockSelection and select RTCClockSelection (LSE, LSI or HSEdiv32)
2. Enable RTC Clock using the __HAL_RCC_RTC_ENABLE() macro.
RM0394
Backup domain access
After a system reset, the backup domain (RTC registers and backup registers) is protected
against possible unwanted write accesses. To enable access to the backup domain,
proceed as follows:
1. Enable the power interface clock by setting the PWREN bits in the Section 6.4.18:
APB1 peripheral clock enable register 1 (RCC_APB1ENR1)
2. Set the DBP bit in the Power control register 1 (PWR_CR1) to enable access to the
backup domain
3. Select the RTC clock source in the Backup domain control register (RCC_BDCR).
4. Enable the RTC clock by setting the RTCEN [15] bit in the Backup domain control
register (RCC_BDCR).
Solved! Go to Solution.
2018-08-08 08:48 AM
2018-08-08 08:48 AM
Don't you have some tamper enabled?
JW
2018-08-08 11:52 AM
Yes, you are correct. I thought I had set the TAMP3NOERASE bit, but I was mistaken.
Thank you.
0x40021058: 1006c401 1 RCC_APB1ENR1_PWREN
0x40007000: 00000300 1 PWR_CR1_DBP
0x40021090: 00008200 2 RCC_BDCR_RTCSEL
0x40021090: 00008200 1 RCC_BDCR_RTCEN
0x40002840: 000000a0 1 RTC_TAMPCR_TAMP3E
0x40002840: 000000a0 0 RTC_TAMPCR_TAMP3TRG
0x40002840: 000000a0 0 RTC_TAMPCR_TAMP3NOERASE
0x40002850: 00000000 0 RTC_BKP0R
SET_BIT(hrtc->Instance->TAMPCR, RTC_TAMPCR_TAMP3NOERASE)
HAL_PWR_EnableBkUpAccess()
__HAL_RCC_RTC_ENABLE()
0x40021058: 1006c401 1 RCC_APB1ENR1_PWREN
0x40007000: 00000300 1 PWR_CR1_DBP
0x40021090: 00008200 2 RCC_BDCR_RTCSEL
0x40021090: 00008200 1 RCC_BDCR_RTCEN
0x40002840: 008000a0 1 RTC_TAMPCR_TAMP3E
0x40002840: 008000a0 0 RTC_TAMPCR_TAMP3TRG
0x40002840: 008000a0 1 RTC_TAMPCR_TAMP3NOERASE
HAL_RTCEx_BKUPWrite(hrtc, 0, 0x12345678)
HAL_RTCEx_BKUPRead(hrtc, 0) = 0x12345678
0x40002850: 12345678 305419896 RTC_BKP0R
>
> md 0x40002800 0xd0
0x40002800: 35 37 04 00 01 21 00 00 00 00 00 00 27 88 00 00 57...!......'...
0x40002810: FF 00 7F 00 FF FF 00 00 00 00 00 00 00 00 00 00 ................
0x40002820: 00 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 ........$.......
0x40002830: 00 00 00 00 01 21 00 00 FD 00 00 00 00 00 00 00 .....!..........
0x40002840: A0 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002850: 78 56 34 12 00 00 00 00 00 00 00 00 00 00 00 00 xV4.............
0x40002860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> mw 0x40002860 -1 4
> md 0x40002800 0xd0
0x40002800: 35 37 04 00 01 21 00 00 00 00 00 00 27 88 00 00 57...!......'...
0x40002810: FF 00 7F 00 FF FF 00 00 00 00 00 00 00 00 00 00 ................
0x40002820: 00 00 00 00 00 00 00 00 87 00 00 00 00 00 00 00 ................
0x40002830: 00 00 00 00 01 21 00 00 FD 00 00 00 00 00 00 00 .....!..........
0x40002840: A0 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002850: 78 56 34 12 00 00 00 00 00 00 00 00 00 00 00 00 xV4.............
0x40002860: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
0x40002870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x40002890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x400028c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
2018-08-09 12:33 PM
Please mark this as answered or correct or whatever mark could be done in this new forum. Thanks.