cancel
Showing results for 
Search instead for 
Did you mean: 

RTC ICSR_INITF (init flag) doesn't set! NUCLEO-U575ZI-Q

Skfir
Senior

Hello friends!

The thing is I have been trying to start the RTC, enable backup domain in PWR, Connect RTC to the bus, set the INIT bit - so far so good, the I

void RTC_init(void){
	RCC->APB3ENR |= (RCC_APB3ENR_RTCAPBEN);		//Power the RTC up
	PWR->DBPR  |= PWR_DBPR_DBP;		//Disable backup domain write protection
	RTC->WPR = 0xCA;	//^Unlock RTC registers
	RTC->WPR = 0x53;
	RTC->ICSR |= RTC_ICSR_INIT;	//Stop RTC and unlock registers
	while(!(RTC->ICSR & RTC_ICSR_INITF)){}	// !!!STUCK HERE!!! Wait for entering the init mode
	RTC->PRER = 0x00007fff;	
	RTC->ICSR &= ~(RTC_ICSR_INIT);	//Finish initialization and start the RTC
}

NIT bit sets fine, but the point is after that the INITF flag doesn't set. Please is someone could point out at the problem. What am I missing? Here is the init code:

1 ACCEPTED SOLUTION

Accepted Solutions
Skfir
Senior

Found the problem! Forgot to select LSE as the RTC clock source: RCC->BDCR |= RCC_BDCR_RTCSEL_0;

View solution in original post

1 REPLY 1
Skfir
Senior

Found the problem! Forgot to select LSE as the RTC clock source: RCC->BDCR |= RCC_BDCR_RTCSEL_0;