2016-12-07 10:37 AM
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
2016-12-07 03:29 PM
If you take a look into the ST code, there is a wait loop right after you enable the write access to backup domain. It can happen that you are configuring the LSEON bit while you can't...
I know you mentioned you are stepping through the code, but maybe...
Renegade
2016-12-07 03:33 PM
Good point. I'll try putting in some delays and see if that helps.