STM32L152
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 5:06 AM
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?
Solved! Go to Solution.
- Labels:
-
RCC
-
RTC
-
STM32L1 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-22 3:38 AM
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 5:09 AM
Use the scope and see if the oscillator is actually oscillating :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 5:15 AM
Custom board? Or DISCO or EVAL board with 32.768 KHz LSE placed?
You mention HSE?​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 5:30 AM
STM32L152_DISCO
I used the oscilloscope of course.
The oscillator doesn't work.
And I used 2 same boards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 5:54 AM
I think you mention LSE. HLE has to be 4MHz+.
Did you enable LSE in your code? By setting BDCR register or using the HAL function like this:
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12;
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
iphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 6:02 AM
Sorry, I wanted to say LSE (32.768KHz) for RTC (external crystal)
Not HSE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 6:09 AM
did you enable it in the software?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 6:18 AM
yes, of course, I enabled it
My interest is just for LSE and how can I start it.
I followed the reference manual. By the way, isn't there the register BDCR for this microcontroller (STM32L152).
LSEON = 1 (RCC_CSR)
LSECSSON = 0 (RCC_CSR)
DBP = 1 (PWR_CR)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 6:35 AM
so check the capacitors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-21 6:49 AM
I have 2 same boards. So I think that the capacitors are OK.
Moreover I replaced the capacitors on the one board.
I suspect the LSE microcontroller behavior. I found some examples on the net about RTC but all of them are using internal 40KHz oscillator(LSI). This is OK. I tried it and it's work fine. But with LSE no chance.
