cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152

costi
Associate III

Hi,

Is there somebody who really used the RTC using external crystal (HSE) of 32.768KHz ?

I tried to use it but with no success.

Using the RTC with internal oscillator of 40KHz (HSI) the all it's OK.

I think that there is a problem with external crystal for this micro. It's possible?

10 REPLIES 10
costi
Associate III

Problem solved.

I have followed the sequence below to start LSE:

.....

1.

GPIOA

For STM32L152 the MCO pin is on the PA8 and this pin has to be set as AF mode.

At this pin it can be shown the desired internal frequency.

An oscilloscope can be use to see the signal.

2.

RCC_CFGR.register

I am taking out the LSE waveform at the microcontroller pin MCO setting the register RCC_CFGR.

MCOPRE = 0 (000: MCO is divided by 1)

MCOSEL = 7 (111: LSE oscillator clock selected)

3.

RCC_APB1ENR register

Set bit PWREN

4.

PWR_CR register

Set bit DBP to have access at RTC

5.

RCC_CSR register

Set bits:

RTCSEL = 01 (01: LSE oscillator clock used as RTC/LCD clock)

LSEON = 1 (1: LSE oscillator ON)

LSECSSON = 0 (0: CSS on LSE (32 kHz oscillator) OFF)

Wait until   LSERDY == 1 (1: External 32 kHz oscillator ready)