cancel
Showing results for 
Search instead for 
Did you mean: 

What is the SPI Timeout for HAL functions exactly?

Chrizzly
Associate III

I want to understand the Timeout parameter of the HAL_SPI_Transmit, HAL_SPI_Receive and HAL_SPI_TransmitReceive function.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

0693W00000GXuHSQA1.png 

And

0693W00000GXuILQA1.png

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

View solution in original post

8 REPLIES 8
Imen.D
ST Employee

Hello @Chrizzly​ ,

I advise your to check the user manual "Description of STM32XXxx HAL driver" (as this User manual), to have an overview of the HAL drivers with the configuration of the functions, and how to use the given API.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Function name
HAL_StatusTypeDef HAL_SPI_Transmit (SPI_HandleTypeDef * hspi, uint8_t * pData, uint16_t Size,
uint32_t Timeout)
Function description
Transmit an amount of data in blocking mode.
Parameters
• hspi: pointer to a SPI_HandleTypeDef structure that contains the configuration information for SPI module.
• pData: pointer to data buffer
• Size: amount of data to be sent
• Timeout: Timeout duration
Return values
• HAL: status

Sorry ST Employee, but i dont see here any info about timeout...

Then for MASTER SPI is timeout only for peripheral is busy from previous oper.

Or Chrizzly and i may ask crash timeout communication when i use lower time as needed to real transfer data?

For SLAVE SPI timeout is for wait to master ? Or plus data time ??? USW.

TDK
Guru

0693W00000GXuHSQA1.png 

And

0693W00000GXuILQA1.png

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

Did you manage to get answer?

I cannot figure out how can transmit on master in blocking mode timeout ?!

  • Master is handling CS
  • Master is handling Clock
  • Master is writing to MOSI and reading from MISO

So even if slave does not exist, is not attached the transmit must go through and transmitreceive will go through and some garbage will be read (from floating pins) but I do not see how a timeout can happen here?

 

I can not understand this too, and I found my code just stuck there for noreason.I can't understand why a master SPI would have a timeout.

I figured it out, on my setup the $@#^#()%$&^ who made the PCB didn't properly connect all the power pins, and power for the USB module was also powering one of the SPI modules so since we did not use USB he didn't connect power to that pin (even worse, he tied it to ground) so SPI module had no power and the software effect was "timeout" for that spi module. Cutting the trace on the board and tying pin to power solved the problem.

emmm, however, my problem is a little weirder. I can transmit, but after a period of continuous sending and receiving, the hal starts to report a timeout, and then after a period of time, it can transmit again, and then it times out again:face_with_rolling_eyes::face_with_rolling_eyes::face_with_rolling_eyes::face_with_rolling_eyes:

 

dunno, the whole "timeout" for spi master makes no sense to me, there should be "other" error message showing what is actually a problem but..

maybe you do not have decoupling cap on all the power pins?