Hi everyone!
I am trying to set up an RTC on stm32f407vgt6 and libopencm3. But I have a problem and I can’t figure out if I did something wrong or if the quartz resonator is faulty.
void rtc_init(void)
{
rcc_periph_clock_enable(RCC_GPIOC);
gpio_mode_setup(GPIOC, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO14 | GPIO15);
gpio_set_af(GPIOC, GPIO_AF0, GPIO14 | GPIO15);
rcc_periph_clock_enable(RCC_PWR);
rcc_osc_on(RCC_LSE);
rcc_wait_for_osc_ready(RCC_LSE); //
RCC_BDCR |= RCC_BDCR_RTCSEL_LSE;
pwr_disable_backup_domain_write_protect();
rcc_periph_reset_pulse(RST_PWR);
rcc_periph_clock_enable(RCC_RTC);
rtc_unlock();
rtc_set_prescaler(0xFF, 0x7F);
RTC_TR = 0;
RTC_DR = 0;
rtc_lock();
pwr_enable_backup_domain_write_protect();
}
The code stops executing here rcc_wait_for_osc_ready(RCC_LSE);
Unfortunately I don’t have an oscilloscope right now and I can’t directly check if the crystal oscillator is working properly. If I have an mistake in my code, I would be grateful if you could point it out to me.