2020-01-03 10:22 PM
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))
{}
}
2020-01-03 11:02 PM
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
2020-01-04 09:07 PM
example code from st. STM8L152