AnsweredAssumed Answered

HAL_SPI_Transmit/HAL_SPI_TransmitReceive timeout

Question asked by Dick Lin on Jul 11, 2018
Latest reply on Jul 11, 2018 by Dick Lin

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;
}
}

Outcomes