Low-Speed Oscillator on STM32F746
I've got a development board based on the STM32F746 from Mikroelektronika. The board has a 32.768 kHz crystal connected to the LSE oscillator pins. I can't get the oscillator to start and come ready.
Here's my code--any idea what I'm doing wrong?
/*
* Start the LSE (32 kHZ) oscillator
*/
RCC->APB1ENR |= RCC_APB1ENR_PWREN; // enable PWR interface clock
PWR->CR1 |= PWR_CR1_DBP; // disable backup domain write protection
RCC->BDCR |= RCC_BDCR_BDRST; // reset backup domain
RCC->BDCR &= ~RCC_BDCR_BDRST; // deassert backup domain reset
RCC->BDCR |= RCC_BDCR_LSEON; // enable LSE oscillator
while(!(RCC->BDCR & RCC_BDCR_LSERDY))
; // wait for LSE ready
RCC->BDCR &= ~(0b11 << 8); //
RCC->BDCR |= 0b01 << 8; // select LSE as RTC clock
RCC->BDCR |= RCC_BDCR_RTCEN; // enable RTC
