I'm trying to run RTC, but there are two problems. 1) It is impossible to write the security key in the WPR register. 2) It is impossible to set the time and date in the TR and DR registers. I tried different methods, but still have not found the answer. Code below.
// Delivered clocks by 32. RCC->CFGR |= RCC_CFGR_RTCPRE_0 | RCC_CFGR_RTCPRE_1 | RCC_CFGR_RTCPRE_2 | RCC_CFGR_RTCPRE_3 | RCC_CFGR_RTCPRE_4; // OK RCC->APB1ENR = RCC_APB1ENR_PWREN; // Enable Backup. OK PWR->CR = PWR_CR_DBP; //OK RCC->BDCR |= RCC_BDCR_BDRST; // Reset register. RCC->BDCR &= ~ RCC_BDCR_BDRST; //Using HSE for RTC. OK. RCC->BDCR |= RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL_0 | RCC_BDCR_RTCSEL_1; //Protection key. // NO effect RTC->WPR = 0xCA; RTC->WPR = 0x53; //Init OK RTC->ISR = RTC_ISR_INIT; //OK while (!(RTC->ISR & RTC_ISR_INITF)); //OK RTC->PRER = 0x7D07D0; //NO effect RTC->TR = 0x194000; //No effect. RTC->DR = 0x198124; //OK. RTC->ISR &=~ RTC_ISR_INIT; //No effect RTC->WPR = 0xFF;