cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I am using NUCLEO-64 STM32F401 and I have attached a serial EEPROM to I2C3. I am using the LL library calls to try to write to the EEPROM but I cant get the slave address to appear on the I2C bus. I do see the start pulse on the scope. Code below.

DCull.1
Associate

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

}

0 REPLIES 0