STM32H743 SPI Master works fine... problem is it should fail :)
Hello, the problem here is that SPI works :) I am successfully using SPI on my STM32H743 MCU for many years now.
Now I encountered the problem with the same code, the same configuration of SPI but the difference is that the slave SPI chip is not there ( a new module with the same chip is not yet assembled). I am running the same code to debug something else , yet this SPI communication returns HAL_OK ! No timeout!
I never had this before ('cause I always had my slave chip connected) . The HAL_SPI_TransmitReceive() function of SPI library still returns HAL_OK :)
Here is a fragment of my code (SPI configured duplex master, data 16-bit, FIFO =1, speed 1.875 MBits/s, software driving CS) :
Spi4NSSEn; // chip select enabled
// addr_cmd[] provides 2 addresses for 2 channels of ADC converter
// pots_bin is a buffer for the ADC result in 0-256 range of POT sweep
if(HAL_SPI_TransmitReceive(&pots_hspi, (uint8_t *)addr_cmd, (uint8_t *)pots_bin, 2, 5000) != HAL_OK ) // transmit and receive 2 data frames (16-bit each)
{
Spi4NSSDis; // chip select dissable
return false;
}
I think that HAL_SPI_TransmitReceive() function should return HAL_TIMEOUT or HAL_ERROR but debugging through the lines looks like everything "works fine" with non-existent slave ! And code seems to be "logical" ... I promise here that SPI slave is not present , MCU is talking to the Universe :)
Please somebody let me know which part of HAL_SPI_TransmitReceive() code should return error from non-existent slave so I could find why it is not getting there.
All library is the latest and so STM32CubeIDE v. 1.18.1
