cancel
Showing results for 
Search instead for 
Did you mean: 

Low-Speed Oscillator on STM32F746

jerry2
Senior
Posted on December 07, 2016 at 19:37

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

11 REPLIES 11
Posted on December 07, 2016 at 23:29

0690X00000605hFQAQ.png

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

Posted on December 07, 2016 at 23:33

Good point. I'll try putting in some delays and see if that helps.