cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L432KB flashes correctly, but debugging works sporadically

EPegu.1
Associate

I have an STM32L432KB that I'm trying to use with STM32CubeIDE and an ST-LINK v3. It is on a small board, and the onboard hardware peripherals connected to the MCU are:

  1.    USB-C connector to dedicated USB pins.
  2.    Quad-SPI flash storage chip
  3.    I2S audio chip

The debugger is connected to:

  1.    Vcc
  2.    GND
  3.    RST
  4.    SWCLK
  5.    SWDIO

I haven't tried to see if the peripherals work yet because I'm just trying to get it debugging reliably. About 1 time out of 10 tries, it will break on main correctly, allow me to step through for a while, then usually will lose connection. When it loses connection, it usually loses it around

MX_USB_DEVICE_Init();

or sometimes

SystemClock_Config();

The other 9 out of 10 times, it does not break at all. When this happens, the IDE automatically opens a tab right after debugging begins and switches to the file called

startup_stm32l432kbux.s

but it does not break on any line in this file, except that this line is always highlighted for some reason:

Reset_Handler:
 ldr sp, =_estack  /* Set stack pointer */

If I pause execution, it will open yet another tab with the name of a memory address, for example:

0x1fff133c

and has the message:

Break at address "0x1fff133c" with no debug information available, or outside of program code.

So the program seems to have gone off into never-never land, assuming the debugger is reporting things accurately.

Note that if I just flash the board and run some code I've written to print serial messages via the USB CDC driver, it works fine. I just cannot figure out why I'm having these debugging issues.

Other details:

  • I had to fit it on a very small board, so I decided to forego a crystal and use the clock recovery system via USB, since my device will always be plugged into USB when in use.
  • HAL_Delay() also seems to give accurate delays, but it's not clear to me if its timebase comes from the USB CRS or the internal oscillator.
  • I've also gotten the I2S output from SAI1B to work

0693W00000AOIQ0QAP.png0693W00000AOIQ5QAP.png 

0693W00000AOIQAQA5.png

1 ACCEPTED SOLUTION

Accepted Solutions

Make sure PH3/BOOT0 is pulled low externally, or you adjust Option Bytes

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

Make sure PH3/BOOT0 is pulled low externally, or you adjust Option Bytes

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Worked perfectly. Thank you so much!