Skip to main content
David.Cheng
Associate III
January 4, 2020
Question

what does the line 6 wait do?

  • January 4, 2020
  • 1 reply
  • 2076 views
void sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead)
{
 //__IO uint32_t timeout = 0xFFFF;
 __IO uint32_t timeout = 0xf00;
 /*!< 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))
 {}
 
 /*!< Send START condition */
 I2C_GenerateSTART(sEE_I2C, ENABLE);
 
 /*!< Test on EV5 and clear it */
 while (!I2C_CheckEvent(sEE_I2C, I2C_EVENT_MASTER_MODE_SELECT))
 {}
 
 
}

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
January 4, 2020

What code is this? On which STM32?

As the comment says, it's a wait between "packets". There's no delay mechanism between STOP and subsequent START at least in some of the I2C modules, so back to back "packets" are confusing some slaves.

Loopdelay is nasty but simple.

JW

David.Cheng
Associate III
January 5, 2020

example code from st. STM8L152