Skip to main content
David.Cheng
Associate III
September 10, 2019
Question

why need so many timeout

  • September 10, 2019
  • 1 reply
  • 482 views
void sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead)
{
 //__IO uint32_t timeout = 0xFFFF;
 __IO uint32_t timeout = 0xFF;
 /*!< Wait the end of last communication */
 for (;timeout > 0; timeout--);
 
 /* Set the pointer to the Number of data to be read. This pointer will be used
 by the DMA Transfer Complete interrupt Handler in order to reset the 
 variable to 0. User should check on this variable in order to know if the 
 DMA transfer has been completed or not. */
 sEEDataReadPointer = NumByteToRead;
 
 /*!< While the bus is busy */
 while (I2C_GetFlagStatus(sEE_I2C, I2C_FLAG_BUSY))

this is std library example code from st office

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
September 10, 2019

I guess it's because I2C slaves may sometimes fail to answer/acknowledge, so that the routine won't hang indefinitely?

JW