Troubleshooting SPI Communication Between STM32G431RB Master and F446RE Slave Boards

I am trying to establish communication between two Nucleo boards (STM32G431RB as master and Nucleo F446RE as slave). I used the example codes from the STM32 GitHub page (NUCLEO-G431RB/Examples/SPI/SPI_FullDuplex_ComPolling_Master and STM32F411RE-Nucleo/Examples_MIX/SPI/SPI_FullDuplex_ComPolling). I made some changes to the slave code, including GPIO settings, but the communication still doesn't work. I chose NSS as [ hspi1.Init.NSS = SPI_NSS_SOFT; ]. The codes also include LED configurations as mentioned in the README files, which indicate an error based on the LED status.I know I have an error acording to led 2 but I don't know the problem. LED2 toggles slowly when there is a timeout or an error in transmission/reception process.
attachment 0
attachment 1
attachment 2
3 Replies
nesnes
nesnes4mo ago
I want to see those transmitted datas in my slave rx_buffer but I can't see it
Alien Queen
Alien Queen4mo ago
@nesnes It sounds like you're close but facing a communication issue between the master (STM32G431RB) and slave (Nucleo F446RE) boards using SPI. you should troubleshoot it by Ensuring the SPI connections (MOSI, MISO, SCK, and NSS) are properly made between both boards. If you’re using SPI_NSS_SOFT, ensure the slave select (NSS) pin is handled manually in software and not left floating. Since you’re using SPI_NSS_SOFT, make sure to manually set the NSS pin to low before communication starts and high after communication ends. If NSS is left incorrectly set, it could prevent proper transmission. Double-check that both the master and slave are configured with the same SPI clock polarity (CPOL) and phase (CPHA). If they are mismatched, the communication might fail, leading to a timeout or data misalignment. Since LED2 is indicating a timeout, increase the timeout value in the HAL_SPI_TransmitReceive function calls, especially on the slave side, to see if that resolves the issue. If the problem persists, testing each component individually may help isolate the issue.
Want results from more Discord servers?
Add your server