2021-08-18 04:43 AM
I think I've set up everything sensibly via STM32CubeMX to get HAL control of the LSE, but the external oscillator appears to be not operable. In particular, there is essentially no voltage on the 32kHz crystal pins, so of course it will not oscillate.
My main() has a calls to SystemClock_Config() and MX_RTC_Init(), which when I step them through appear to do sensible things, but still no volts on the LSE pins and still no oscillation.
Is there something more I must do, please?
Thanks.
Gordon.
2021-08-18 05:11 AM
Which STM32? What hardware? A "known good" such as Nucleo or Disco board? If not, what exactly are the connections and layout?
LSE is an extremely low-power oscillator, so measuring on its pins using common probes/oscilloscope etc. more-less guarantees that there will be no oscillations.
If in doubts whether the software does what it should do, read out and check/post content of relevant RCC register(s) (depending on STM32 model).
JW
2021-08-18 07:13 AM
STM32L081. Own hardware.
The crystal is on the the pins PC14 & PC15, with 10pF from each crystal pin to ground. The traces are essentially straight but quite long, run as a pair on the non-component side of the board. They're close to 20mm. The traces presently pass below the HSE crystal, though the latter will likely never be used. The signals all measure high-resistance with a multimeter, so I think there are no short-circuits.
Your second line may tell the story. I'm surprised to see no volts with a 10M probe, but it's certainly possible. I'm used to oscillation stopping when probed, but much less used to seeing no voltage on the pins. As you say, the LSE is very low power.
I have seen values in the minutes and seconds data, which suggests it's running from some clock, though at present the time appears to start from scratch each power-up, which suggests I need to stop some part of the initialisation, once I'm happy that the 32kHz really is running reliably.
I do have an STM32L053-DISCO and two types of STM32L1 discovery boards, so could compare with those.
I have yet to find out whether the STM32CubeIDE will allow me to view special-purpose registers, though I can read them explicitly in the software, of course.
I think I'll proceed by presuming for now that this is a Schroedinger-type problem just try reading the RTC periodically and see if it looks to be changing sensibly.
2021-08-18 07:29 AM
The time is definitely changing.
I think that must mean that the LSE is running.
At present it gets zeroed at every restart, so I obviously I have to check for something before allowing MX_RTC_Init() to set the RTC data.
2021-08-19 03:30 AM
> I think that must mean that the LSE is running.
It may be also running from LSI.
Read out and check/post content of RCC_CSR.
JW
2021-08-19 04:58 AM
RCC_CSR:
470090496
0x1C:05:03:00
... so
RTC is on and clocked by LSE
LSEDRV is lowest, LDE-bypass is off, LSE is ready, LSE is ON.
LSI is off; not ready.
all of which sounds right to me.
I've also now stopped the RTC being reset to zero at each reset of the CPU.
Gordon.
2021-08-26 06:53 AM
As an addendum to this, if I try to run the same firmware on a board without a 32kHz crystal, the code ends up in an error loop indicating that the LSE didn't run.
QED.