2019-10-22 07:03 AM
The datasheet states:
>ADDR: Address sent (master mode)/matched (slave mode) This bit is cleared by software reading SR1 register followed reading SR2.
In case a single byte has to be received, the Acknowledge disable is made during EV6 (before ADDR flag is cleared) and the STOP condition generation is made after EV6.
If I write any instruction (or declaration) between `I2C->DR=address|0` and `while(!(I2C2->SR1 & (1<<1)))` in below code, then ADDR flag is cleared without reading the SR2 register (`I2C2->SR2`).
if(direction==i2c_transmitter_mode)
{
I2C2->DR = address ;//SEND ADDRESS WITH ZERO LAST BIT
while(!(I2C2->SR1 & (1<<1)))
{
if(--i2c1_timeout==00)
{
return 1;
}
}
I2C2->SR2;
return 0;
}
I am sending WHO_AM_I register address and getting 0x68h.so,ADDR and TXE bits are set.but ADDR flag is being cleared immediately.
How can I fix this problem?
2019-10-22 07:24 AM
>>How can I fix this problem?
perhaps you could use the libraries using the memory addressing API function?