Problem to read more then 256 bytes form I2C slave

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

cross mob
jawa_294416
Level 1
Level 1
First like received

 Hi,

   

How we can read I2C master more then 256 bytes from slave? Both Master and slave I2C are using PSOC 3.

   

Slave I2C Sub_Address size(bits) = 16 bits.

   

    typedef struct _EZI2C_REGS

   

    {

   

 

   

        uint16 stat;    /* R/W variable         */

   

        uint16 cmd;   /* R/W variable         */

   

        uint16 volts[3][3]; /* R/W variable         */

   

        uint16 str[6u];    /* Read only to I2C     */

   

    } EZI2C_REGS;

   

EZI2C_REGS  readI2cRegs; 

   

I2C_UDB_M_MasterReadBuf()  function :automatically reads an entire buffer of data from a slave device. We can't use this function to read single array data or specific location to the stucture.

   

We try the code on following and it failed to provide correct data.

   

I2C_UDB_M_MasterClearStatus();

   

CyDelay(2);

   

I2C_UDB_M_MasterReadBuf(EZI2C_SLAVE_ADDR, (uint8 *)&readI2cRegs.volts[0], sizeof(readI2cRegs.volts[0]) , I2C_UDB_M_MODE_COMPLETE_XFER);

   

while(0u == (I2C_UDB_M_MasterStatus() & I2C_UDB_M_MSTAT_RD_CMPLT))

   

 {

   

 } 

   

 

   

I2C_UDB_M_MasterReadBuf(EZI2C_SLAVE_ADDR, (uint8 *)&readI2cRegs.volts[1], sizeof(readI2cRegs.volts[1]) , I2C_UDB_M_MODE_COMPLETE_XFER);

   

while(0u == (I2C_UDB_M_MasterStatus() & I2C_UDB_M_MSTAT_RD_CMPLT))

   

 {

   

 } 

   

 

   

    LCD_PrintInt16(readI2cRegs.volts[0][0]);

   

    LCD_PrintInt16(readI2cRegs.volts[0][1]);

   

    LCD_PrintInt16(readI2cRegs.volts[0][2]);

   

 

   

It only working by following code. The problem that we need to read more then 256 byte from the slave. How we can do it?

   

I2C_UDB_M_MasterReadBuf(EZI2C_SLAVE_ADDR, (uint8 *)&readI2cRegs, sizeof(readI2cRegs) , I2C_UDB_M_MODE_COMPLETE_XFER);

   

 

   

Thanks

0 Likes
7 Replies