Ich deaktiviere den Schreibschutz und das DBP Flag. Die Uhr läuft und behält ihre Uhrzeit mit der Batterie (LSE). Ein Schreibzugriff mit folgender Routine bewirkt keine Änderung im TR oder DR. Was mache ich falsch?
1 | RTC->WPR = 0xCA; |
2 | RTC->WPR = 0x53; |
3 | RTC->ISR |= RTC_ISR_INIT; |
4 | while(!(RTC->ISR & RTC_ISR_INITF)); |
5 | |
6 | RTC->TR = 0; |
7 | RTC->DR = 0; |
8 | RTC->TR |= (uint32_t)(val2bcd(oRTC.u8Hours / 10) & 0x03) << 20; |
9 | RTC->TR |= (uint32_t)(val2bcd(oRTC.u8Hours % 10) & 0x0f) << 16; |
10 | RTC->TR |= (uint32_t)(val2bcd(oRTC.u8Minutes / 10) & 0x07) << 12; |
11 | RTC->TR |= (uint32_t)(val2bcd(oRTC.u8Minutes % 10) & 0x0f) << 8; |
12 | RTC->TR |= (uint32_t)(val2bcd(oRTC.u8Seconds / 10) & 0x07) << 4; |
13 | RTC->TR |= (uint32_t)(val2bcd(oRTC.u8Seconds % 10) & 0x0f) << 0; |
14 | |
15 | RTC->DR |= (uint32_t)(val2bcd(oRTC.u8Year / 10) & 0x0f) << 20; |
16 | RTC->DR |= (uint32_t)(val2bcd(oRTC.u8Year % 10) & 0x0f) << 16; |
17 | RTC->DR |= (uint32_t)(val2bcd(oRTC.u8Month / 10) & 0x01) << 12; |
18 | RTC->DR |= (uint32_t)(val2bcd(oRTC.u8Month % 10) & 0x0f) << 8; |
19 | RTC->DR |= (uint32_t)(val2bcd(oRTC.u8Day / 10) & 0x03) << 4; |
20 | RTC->DR |= (uint32_t)(val2bcd(oRTC.u8Day % 10) & 0x0f) << 0; |
21 | |
22 | RTC->ISR &= ~RTC_ISR_INIT; |