Skip to main content
Dick Lin
Senior
July 11, 2018
Question

HAL_SPI_Transmit/HAL_SPI_TransmitReceive timeout

  • July 11, 2018
  • 2 replies
  • 1297 views
Posted on July 11, 2018 at 20:13

Hi,

I used to have the SPI1 working connected to MAX31865 breakout board. For some reason it's not working at all now. I traced into the code, seems HAL_SPI_Transmit() failed on 

__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE) until timeout.

Seems the TXE flag never get set. Not sure what's going on. 

And all of the SPI1 instance registers (CR1, CR2, SR, DR...) have value 0. See below screen shot.

I am kind of don't believe all the registers value be 0 first. Secondly it used to be functional not long ago.

Is there anything I am missing here?

Thx

if (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXE))

{

if (hspi->TxXferCount > 1U)

{

/* write on the data register in packing mode */

hspi->Instance->DR = *((uint16_t *)pData);

pData += sizeof(uint16_t);

hspi->TxXferCount -= 2U;

}

else

{

*((__IO uint8_t *)&hspi->Instance->DR) = (*pData++);

hspi->TxXferCount--;

}

}

else

{

/* Timeout management */

if ((Timeout == 0U) || ((Timeout != HAL_MAX_DELAY) && ((HAL_GetTick() - tickstart) >= Timeout)))

{

errorcode = HAL_TIMEOUT;

goto error;

}

}0690X0000060M7uQAE.png
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    July 11, 2018
    Posted on July 11, 2018 at 20:34

    Suggests you haven't enabled the SPI1 clock.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Dick Lin
    Dick LinAuthor
    Senior
    July 11, 2018
    Posted on July 11, 2018 at 20:48

    Yeah, you are right. This is the new project I just created to isolate the SPI issue I am seeing not sending out data. Now I have it fixed and able to see the registers value. Thx