cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 SPI Issues

MAgui.1
Associate II

Hello, I am running into an issue using the SPI functionality on my STM32H7 chip that is on a custom made board. What I am trying to do is read an adas3022 adc (Link to datasheet below) on a spi peripheral from the STM32H7. I have written functions for the spi protocol that are run in some tasks using freeRTOS. However, even outside of the task, just inside of the main while loop, it seems to not show the pulse of the clock. The gpio pins are shown to be correct (high and low) but the clock pin is not showing anything on the oscilloscope at all. The code also gets stuck on the second loop around waiting for the spi peripheral to get ready but it never does. There is a workaround suggested in the following forum and manual that I have read but it doesn’t seem to work. Below are screenshots of the main code and links to the manual and forum:

0693W00000FCia7QAD.pngFigure1: part 1 of my spi_protocol() function.

0693W00000FCiaCQAT.pngFigure2: part 2 of my spi protocol function.

0693W00000FCiZbQAL.pngFigure 3: part 1 of my main while loop with the enable and workaround shown.

0693W00000FCiaHQAT.pngFigure 4: part 2 of the main while loop with disable and abort used for testing the spi and trying to get it unstuck.

0693W00000FCiaMQAT.pngFigure 5: the spi configuration that has been set up.

0693W00000FCiaRQAT.pngFigure 6: the clock configuration that has been set up.

Link 1: adas 3022 datasheet

https://www.analog.com/media/en/technical-documentation/data-sheets/ADAS3022.pdf

Link 2: Forum discussing the potential workaround that doesn't seem to work for us:

https://stackoverflow.com/questions/57919896/disabling-spi-peripheral-on-stm32h7-between-two-transmissions

Link 3: the manual that on the limitations of the h7 that is also referenced in the forum discussion in link 2:

https://www.st.com/resource/en/errata_sheet/es0392-stm32h742xig-and-stm32h743xig-device-limitations-stmicroelectronics.pdf

Not sure where the issue is but we've definitely hit a wall and not sure where to go next in the debugging process. If there is anything that I can expand on I am happy to do so and any and all suggestions help. Thank you for your help and patience!

2 REPLIES 2
TDK
Guru

Do you call HAL_SPI_Init somewhere?

I would get it working without DMA first, then add that part later on. It doesn't look like you're waiting for the DMA transaction to finish before starting the next one. Monitor the return value from HAL functions and do something useful when it's not HAL_OK such as logging the error to a UART stream so you can debug it properly.

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

I call HAL_SPI_Init() for each of the spi devices (although right now I am only focused on spi1). I have tried with and without the DMA and the problem seems to be the same. I have used the debugging tree in cubeide to hunt down where it gets hung up but I didn't log it. I'll debug again and post a screenshot of where it is calling the error handler. Do you possibly have an idea as to why the spiclk pin is not sending out a pulse/ not seen on the oscilloscope? Thank you for your help I appreciate it!