Skip to main content
DRich.4
Associate II
October 15, 2020
Question

Enabling LSE clock on PA8 from HEX code?

  • October 15, 2020
  • 8 replies
  • 2625 views

I am unable to communicate with the MCU via UART (115200 bit/s). It looks like the program inside MCU is not running. I think the problem can be probably in not running LSE 32.768kHz crystal oscillator.

Is it possible to enable LSE clock on PA8 if I have just the hex file to check it with oscilloscope? SWD via STLINK-V3MINI and STM32CubeProgrammer works great, I was able to upgrade the firmware with easy. I have S76G chip with STM32L07 inside.

This topic has been closed for replies.

8 replies

waclawek.jan
Super User
October 15, 2020

Write a short program which only enables LSE, and make sure it runs (output it to MCO for example and measure there).

Then, if without disconnecting power you load the firmware in question, LSE should keep running, unless that firmware explicitly resets the backup power domain.

A better solution is to load the firmware through a debugger and run it there, and then observing the LSE-related registers and/or manipulating them; but it's not something commonly used and the exact steps will be toolchain dependent.

You may also want to ask the "chip" (module) vendor for help.

JW

DRich.4
DRich.4Author
Associate II
October 15, 2020

That's a good idea to write a short program and enable LSE on MCO output and test it. The problem is that I never worked with STM MCU's, I am working with Microchip AVR MCU's ATtiny202 & SAMR34 in MPLAB X IDE and Atmel Studio. I don't know how to write a short program for STM and where. Can I use STM32CubeProgrammer? I assume the STM32L07 MCU is using it's internal HS oscillator.

Actually I don't need to program STM MCU as I am using special S76G chip which includes SX1276 Transceiver, STM32L07 MCU and SONY GPS CXD5603GF. I just need to send a few AT commands via S76G USART, which is not working now, to achieve required functionality I have tested successfully on development system already. The S76G is delivered with firmware already.

I designed my own PCB - Micro Cat Tracker (26.5 x 12 x 1.5 mm; 1 x 1/2 x 1/16 inches) sewn into cat collar. See attached picture.

Tesla DeLorean
Guru
October 15, 2020

There is a free license for Keil on ST CM0(+) parts. https://www2.keil.com/stmicroelectronics-stm32/mdk

You could perhaps build/debug code in RAM (0x20000000) if programming the FLASH is not desirable. Perhaps modify the peripheral / RCC registers directly. I think the current STM32 Cube Programmer can give you some register level access if you're willing to walk the chip into the mode/settings you want.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
October 15, 2020

ACSIP STM32L073 https://www.richardsonrfpd.com/Products/Product/S76G

24 MHz HSE, would need to have HSE_VALUE defined correctly

Yes, LSE is routable

https://www.st.com/resource/en/reference_manual/dm00095744-ultralowpower-stm32l0x3-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

7.2.14 Clock-out capability The microcontroller clock output (MCO) capability allows the clock to be output onto the external MCO pin using a configurable prescaler (1, 2, 4, 8, or 16). The configuration registers of the corresponding GPIO port must be programmed in alternate function mode. One of 7 clock signals can be selected as the MCO clock: • SYSCLK • HSI16 • HSI48 • MSI • HSE • PLL • LSI • LSE The selection is controlled by the MCOSEL[3:0] bits of the RCC_CFGR register (see Section 7.3.20). For code example, refer to A.4.3: MCO selection code example.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
gregstm
Senior II
October 16, 2020

" It looks like the program inside MCU is not running" - if possible - toggle pins, flash leds etc. to check that the code progresses before you even get to enabling the LSE

DRich.4
DRich.4Author
Associate II
October 16, 2020

I created test program in STM32CubeIDE, just to enable LSE on MCO PA8 pin and found out the LSE is not running (as I assumed). When I touch crystal by a finger I get random oscillations I catched on attached oscilloscope screenshots.

I don't like to rebuild PSB so I will try to replace the crystal with two CL capacitors by MEMS oscillator and will check the output again.

0693W000004K5CwQAK.png0693W000004K5D7QAK.png 

Clock Configuration picture here

waclawek.jan
Super User
October 16, 2020

> I will try to replace the crystal with two CL capacitors by MEMS oscillator

Note, that that might require to set the bypass (LSEBYP). I am not sure what happens if you don't do that, and what is the impact on LSERDY - that all might make troubles in the original firmware.

Before you do the hardware change, you might want to play with LSEDRV, and also try to carefully wash/clean the surroundings of the crystal.

JW

DRich.4
DRich.4Author
Associate II
October 16, 2020

Maybe the PCB design (4 layers) is responsible for not working LSE. I didn't expect any problems with 32.768 kHz. U3 is TCVCXO oscillator 26 MHz running well (Vpp = 1V).

Crystal used TFX-03 (+/-20ppm, CL=5pF), capacitors 6 pF.

STM32L073x, probably STM32L073CZUx in SiP (System in Package) S76G chip.

0693W000004K6UIQA0.jpg

waclawek.jan
Super User
October 17, 2020

IMO the PCB design is OK, capacitors sound roughly OK too.

If this is a prototype, double/triple check if you don't have shorts between pins/tracks. Try a different crystal - what if it got damaged during soldering and/or tests?

In the test program, make sure it does not time out and give up or switch to LSI too soon. Starting up a low-power crystal oscillator make last seconds or even tens of seconds.

Try the test program on a "known good" board such as Nucleo or Disco (or on the devboard you say is OK, if you are confident you can revert to the original firmware on it).

JW

PS. Cross-posted on a local forum.

DRich.4
DRich.4Author
Associate II
October 17, 2020

When I changed the RCC_LSEDRIVE_LOW to HIGH it help to start the crystal by touching it by a finger, but the output frequency is 1/2 of 32.768KHz see picture:

0693W000004K8XYQA0.png 

I noticed that the crystal is soldered upside down i.e. Pin 1 input is going to OSC32_IN and Pin 2 output is going to OSC32_OUT. That may be the problem.

DRich.4
DRich.4Author
Associate II
November 2, 2020

I have slightly modified the design for MEMS oscillator (SiT1533AI-H4-AA3-32.768E). Waiting for a new PCB to test it. Stay tuned ;-).

0693W000005A6lrQAC.png