2021-10-15 03:46 PM
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:
Figure1: part 1 of my spi_protocol() function.
Figure2: part 2 of my spi protocol function.
Figure 3: part 1 of my main while loop with the enable and workaround shown.
Figure 4: part 2 of the main while loop with disable and abort used for testing the spi and trying to get it unstuck.
Figure 5: the spi configuration that has been set up.
Figure 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:
Link 3: the manual that on the limitations of the h7 that is also referenced in the forum discussion in link 2:
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!
2021-10-15 04:34 PM
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.
2021-10-19 07:44 AM
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!