AnsweredAssumed Answered

kl25 I2C_HAL_WriteByte()

Question asked by Edriano Araujo on Mar 14, 2016
Latest reply on Mar 16, 2016 by Edriano Araujo

Hello.

I am currently writing an I2c Baremetal function.

and after a long time testing and analyzing the data i could realize that   ITCF and  RXAK flags does not work as i thought.

after sending a byte to I2c if i try to test either TCF and RXAK both of them are true and i start to overwrite the data register. if i use the code below nothing works. i already found a way to solve that testing the IICIF flag. this one works.

but my question is. doesnot this flags works at all? i am assuming something wrong?

 

I2C_HAL_WriteByte(I2C0,0xA0);

while((I2C0_S & I2C_S_TCF_MASK )==0){}

I2C_HAL_WriteByte(I2C0,0x00);

while((I2C0_S & I2C_S_TCF_MASK )==0){}

I2C_HAL_WriteByte(I2C0,0x00);

while((I2C0_S & I2C_S_TCF_MASK )==0){}

 

also if i use RXAK the same problem occurs

 

I2C_HAL_WriteByte(I2C0,0xA0);

while((I2C0_S & I2C_S_RXAK_MASK )==0){}

I2C_HAL_WriteByte(I2C0,0x00);

while((I2C0_S & I2C_S_RXAK_MASK )==0){}

I2C_HAL_WriteByte(I2C0,0x00);

while((I2C0_S & I2C_S_RXAK_MASK )==0){}

 

the code below works fine.

 

  I2C_HAL_SendStart(I2C0);

  I2C0_S |= I2C_S_IICIF_MASK;

  I2C_HAL_WriteByte(I2C0,endereco);

  while((I2C0_S & I2C_S_IICIF_MASK)==0){}

 

  I2C0_S |= I2C_S_IICIF_MASK;

  I2C_HAL_WriteByte(I2C0,0x00);

  while((I2C0_S & I2C_S_IICIF_MASK)==0){}

 

  I2C0_S |= I2C_S_IICIF_MASK;

  I2C_HAL_WriteByte(I2C0,0x00);

  while((I2C0_S & I2C_S_IICIF_MASK)==0){}

Outcomes