i2c transfert reads one more byte than requested

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello.

I've found a bug in the i2c_transfer_message_no_dma function.

wiced 3.0.0, STM32F2, platform_i2c.c line 685.

The i2c transfert function reads one more byte than requested, making the cursor of my eeprom device I'm driving one byte ahead, making next sequencial read erroneous.

Existing code:

            if ( i == ( message->rx_length - 1 ) )
            {
                /* setup NACK for the last byte to be received */
                I2C_AcknowledgeConfig( i2c->port, DISABLE );
            }

Replace with:

           if(message->rx_length == 1) continue;


            if ( i == ( message->rx_length - 2 ) )
            {
                /* setup NACK for the last byte to be received */
                I2C_AcknowledgeConfig( i2c->port, DISABLE );
            }

0 Likes
11 Replies