How to configure RTC in STM32F429ZI? I have problem with starting RTC, starting WKUP timer.
I try to start RTC in my STM32F429 (I do not use HAL libraries and I want not to use it). I use registers directly or with use of libopencm3.
I want to run RTC and Wakeup timer with LSI source now and the RTC_TR is always 0 and RTC_DR 00002101h (and doesn't increment.
What I do wrongly? Can you please help me? I try THIRD day run RTC without success :-(.
Here is initialization code:
static void enableRTC(void)
{
rcc_periph_clock_enable(RCC_GPIOC);
rcc_periph_clock_enable(RCC_GPIOA);
// unlock
RTC_WPR=0xCA;
RTC_WPR=0x53;
PWR_CR|=PWR_CR_DBP;
// reset RTC settings
RCC_BDCR|=RCC_BDCR_BDRST;
RCC_BDCR&=~RCC_BDCR_BDRST;
// enable RTC without LSE
uint32_t tmp=RCC_BDCR;
tmp|=RCC_BDCR_RTCEN;
tmp&=~RCC_BDCR_LSEON;
tmp&=~RCC_BDCR_LSEBYP;
// enable RTC from LSI
tmp&=~(RCC_BDCR_RTCSEL_MASK<<RCC_BDCR_RTCSEL_SHIFT);
tmp|=RCC_BDCR_RTCSEL_LSI<<RCC_BDCR_RTCSEL_SHIFT;
RCC_BDCR=tmp;
debug=RCC_BDCR; // for display purpose 8200h in register
//while(!(RCC_BDCR & RCC_BDCR_LSERDY)) continue; // only for LSE
// set wakeup timer
RTC_WPR=0xCA; // unlock
RTC_WPR=0x53;
RTC_CR=0x20;
while(!(RTC_ISR & RTC_ISR_WUTWF)) continue;
RTC_WPR=0xCA; // unlock
RTC_WPR=0x53;
RTC_WUTR=300;
RTC_CR=RTC_CR_WUTE|RTC_CR_WUTIE|0x20; //set interrupt, set wakeup timer
RTC_WPR=0;
debug2=RTC_CR; // 4420h in the register
debug3=RTC_WUTR; // 12Ch in the register
// enable wakeup interrupt
nvic_enable_irq(NVIC_RTC_WKUP_IRQ);
nvic_set_priority(NVIC_RTC_WKUP_IRQ, 1);
exti_enable_request(EXTI22);
exti_set_trigger(EXTI22, EXTI_TRIGGER_RISING);
}The RTC_ISR is STILL 7 (read in loop and displayed in main() function). The WUTF flag is present never. Why?
RTC_TR is also still 0. It doesn't inrement.
If you cannot find error in my code, can you please give minimal code (with use of registers) how to start RTC (RTC_TR increments, WAKEUP works)?
