cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 I2C ''ACK Polling''

Artur1
Associate II
Posted on January 18, 2012 at 12:40

Hi all,

I need an expert advice. How to poll for ACK from addressed Slave device? The background is, if the setup has a variable count of slaves and how to get the available slaves? The second case is the M24C64 EEprom. During the internal Write cycle, the device discon-

nects itself from the bus, so I need to poll on ACK. But with my solution I get always an endless loop Between write byte and read byte function. If I use instead the do-while Delay(1) everything seems to be ok. This was very easy on an Atmega to check for ACk on device addessing, I've spent a lot of time to get this on STM32, but without success.

void

eeprom_wait_for_ready (void) {

    /*

    unsigned char state = 0;

    do

    {

        while(I2C_GetFlagStatus(I2C_SELECTED, I2C_FLAG_BUSY));

        // Send START condition

        I2C_GenerateSTART(I2C_SELECTED, ENABLE);

        // Test on EV5 and clear it

        while(!I2C_CheckEvent(I2C_SELECTED, I2C_EVENT_MASTER_MODE_SELECT));

        // Sent slave address for write

        I2C_Send7bitAddress(I2C_SELECTED, EEPROM_I2C_ADDR, I2C_Direction_Transmitter);

        state = I2C_CheckEvent(I2C_SELECTED, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED);

        printf(''\r\n.'');

        I2C_GenerateSTOP(I2C_SELECTED, ENABLE);

    } while (!state);

    */

    /**/

     Delay(1);

    

}

Thx for helping.
0 REPLIES 0