Cypress I2C slave sends 0xff

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

cross mob
Anonymous
Not applicable

Hello, 

   

I am using cypress CYBL10161-56LQXI. I am using I2C as a slave. I have a problem that after my slave sends the desired data, in the next cycle when master asks the slave if any data is available and if there is no data available, the cypress sends 0xff,0xff....[Buffer length].

   

 

   

I am using this, 

   


            strncpy(i2cReadBuffer,"abcd",sizeof("abcd"));
                  
        if(0u != (I2C_I2CSlaveStatus() & I2C_I2C_SSTAT_RD_CMPLT))
            {
                
                   // Clear slave read buffer and status 
                      I2C_I2CSlaveClearReadBuf();
               (void) I2C_I2CSlaveClearReadStatus();
              
            } 

   

So here, master would receive abcd first then it receives 0xff,0xff.... It would be great if you could help me out with that.

   

Thanks.

0 Likes
2 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello Dharav,

   

Can you please attach the project? Also please let us know which device you are using as I2C Master?

   

Thanks,

   

Hima

0 Likes
Anonymous
Not applicable

Hi Hima, 

   

I am using STM32L0xx as master with the i2c, but I even receive the 0xFFs on the Bridge control panel. This is how I initialize my read buffer,

   

#define BUFFER_SIZE_I2C_SLAVE 120

   

uint8 i2cWriteBuffer[120];
uint8 i2cReadBuffer[120];

   

void main()

   

{

   

    CyGlobalIntEnable;

   

    I2C_I2CSlaveInitReadBuf(i2cReadBuffer,BUFFER_SIZE_I2C_SLAVE);    
    I2C_I2CSlaveInitWriteBuf(i2cWriteBuffer,  BUFFER_SIZE_I2C_SLAVE);
    
    I2C_Start();

   

 }

   

And then at certain points I call my function, for now it is, 

   

SendI2C(void)

   

{

   

    static char i2cCmd[120] = {0x00,};

   

    char data[BUFFER_SIZE_I2C_SLAVE]= {0x04,'a','b','c',0x03};
    const char commandStart[] = "\x04 ";        //Start of packet
    const char commandEnd[] = " \x03";         //End of packet

   

    memset(i2cCmd,0,sizeof(i2cCmd));        
     
            strncpy(i2cCmd, commandStart, sizeof(commandStart));
            strncat(i2cCmd, data, sizeof(data));
            strcat(i2cCmd, commandEnd);
     

   

    strncpy(i2cReadBuffer,i2cCmd,sizeof(i2cCmd));

   

    if(0u != (I2C_I2CSlaveStatus() & I2C_I2C_SSTAT_RD_CMPLT))
    {              
                // Clear slave read buffer and status
                      I2C_I2CSlaveClearReadBuf();
               (void) I2C_I2CSlaveClearReadStatus();                   
     } 

   

}

   

I check my results on the Bridge control panel using "r 08 x x x x x x x x x p", I get desired results, that is, 

   

r 08+ 04+ 20+ 04+ 61+ 62+ 63+ 03+ 20+ 03+ p ,

   

 

   

But when I do the repeat on the Bridge control panel (which will do the reads in loop), I see the following 

   

 

   

r 08+ 04+ 20+ 04+ 61+ 62+ 63+ 03+ 20+ 03+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 04+ 20+ 04+ 61+ 62+ 63+ 03+ 20+ 03+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 04+ 20+ 04+ 61+ 62+ 63+ 03+ 20+ 03+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ 00+ p 
r 08+ 00+ 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