2020-09-10 09:03 AM
The code below gets stuck at ---
while (!txBytes)
txBytes=LL_I2C_IsActiveFlag_ADDR(I2C3);
and the ADDR bit never gets read as set?
==========================================
void I2C_Write(uint8_t dataCount, uint8_t data)
{
uint8_t I2CAddrWrite = 0xa0;
uint8_t EEAddress[2] = {0x00,0x00};
uint8_t rxbyte = 0x00;
uint32_t txBytes=0;
LL_TIM_DisableIT_UPDATE(TIM2);
// send start
LL_I2C_GenerateStartCondition(I2C3);
// check for busy
while (LL_I2C_IsActiveFlag_BUSY(I2C3)==FALSE) ;
// write slave address for write ( 0 in bit0)
LL_I2C_TransmitData8(I2C3, I2CAddrWrite);
txBytes=LL_I2C_IsActiveFlag_ADDR(I2C3);
//while (LL_I2C_IsActiveFlag_ADDR(I2C3)==FALSE) ;
while (!txBytes)
txBytes=LL_I2C_IsActiveFlag_ADDR(I2C3);
LL_I2C_ClearFlag_ADDR(I2C3);
while (LL_I2C_IsActiveFlag_TXE(I2C3)==FALSE) ;
LL_I2C_TransmitData8(I2C3, EEAddress[0]);
while (LL_I2C_IsActiveFlag_TXE(I2C3)==FALSE) ;
LL_I2C_TransmitData8(I2C3, EEAddress[1]);
if(dataCount!=0)
{
while (LL_I2C_IsActiveFlag_TXE(I2C3)==FALSE) ;
LL_I2C_TransmitData8(I2C3, data);
}
while (LL_I2C_IsActiveFlag_TXE(I2C3) == FALSE || LL_I2C_IsActiveFlag_BTF(I2C3)==FALSE) ;
LL_I2C_GenerateStopCondition(I2C3);
LL_TIM_EnableIT_UPDATE(TIM2);
}