cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SPI_ENABLE causes crash/reset on STM32G030J6

LMeye.1
Associate III

I am trying to communicate with an SD card using SPI.

I have found a library, that can work on an STM32g031f6, but if I try to do the same on an STM32g030j6, it crashes/resets when it calls the function "__HAL_SPI_ENABLE" in "stm32g0xx_hal_spi.c".

I have attached an image of the wiring, normally I would use PA13 fo SD_CS, but I have changed it to PC14, so I can debug the chip.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

You have SPI_SCK going on the NRST pin. When it sets the clock low, it pulls NRST down and resets the chip. You need to leave that pin alone per the datasheet:

0693W00000GXIn6QAH.png 

You can also disable the NRST functionality at your own peril, even though it's not a supported feature on this chip. Note that this is a good gateway towards bricking your chip.

https://community.st.com/s/question/0D53W00000wy2Gf/can-the-stm32g030-nrst-pin-disabled-or-be-used-as-gpio

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
TDK
Guru

Read out the RCC->CSR registers to determine the cause of the reset. Monitor the voltage rail to ensure power isn't lost. Ensure watchdogs are disabled.

The STM32G030 and the STM32G031 have the same SPI peripheral, so the answer lies elsewhere. Probably in the hardware.

If you feel a post has answered your question, please click "Accept as Solution".
LMeye.1
Associate III

I have attached an image of the CSR registers, they don't seem to change at any time.

The power for the chip, comes from a Constant Voltage power supply at 3.3v, so that shouldn't be an issue.

I am not quite sure how to check the watchdog status.

TDK
Guru

You have SPI_SCK going on the NRST pin. When it sets the clock low, it pulls NRST down and resets the chip. You need to leave that pin alone per the datasheet:

0693W00000GXIn6QAH.png 

You can also disable the NRST functionality at your own peril, even though it's not a supported feature on this chip. Note that this is a good gateway towards bricking your chip.

https://community.st.com/s/question/0D53W00000wy2Gf/can-the-stm32g030-nrst-pin-disabled-or-be-used-as-gpio

If you feel a post has answered your question, please click "Accept as Solution".
LMeye.1
Associate III

I am unable to use other pins for the SPI configuration, as both SPI 1&2 needs pin 8, but I will try and see if I can disable the reset pin.