I2C Slave Operation Only Sends The First Byte

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

cross mob
JoLo_4180566
Level 2
Level 2

I am using the CCG3PA as a slave device. I am using the callback example provided and seem to only send one byte when the master polls. In this particular case, when the master polls, the slave should respond with 4 bytes. I am getting the first one with 0xFFs after that. The clocks are being sent by the master so it isn't the master. I am looking at the signals with a scope. It seems that the slave is not sending the whole buffer. I initialize the buffer with I2C_1_I2CSlaveInitReadBuf(). The callback simply sets a flag and my loop is per the example, i.e. checks flag and master write complete. A small snippet of code which is almost identlcal to the example is below. The ISR is a stock generated ISR which looks like it will send until the buffer size has been sent.

Any help will be appreciated.

        // Master has finished writing to the slave

        if (I2CFlag)

        {

            I2CFlag = false;

           

            /* Check if master write is complete */

            if (0u != (I2C_1_I2C_SSTAT_WR_CMPLT & I2C_1_I2CSlaveStatus()))

            {

                /* Validate the packet frame */

                //uint8_t packet_size = I2C_1_I2CSlaveGetWriteBufSize();

               

                /* Check start and end of transmission characters */

                pd_control_parse_message(); /* fills buffer with response */

                /* Clear the slave write buffer for next write */

                I2C_1_I2CSlaveClearWriteBuf();

                (void) I2C_1_I2CSlaveClearWriteStatus();

            }

           

            /* Read Complete: Expose buffer to master */

            if(0u != (I2C_1_I2C_SSTAT_RD_CMPLT & I2C_1_I2CSlaveStatus()))

            {

                /* Clear the slave read buffer for next read */

                I2C_1_I2CSlaveClearReadBuf();

                (void) I2C_1_I2CSlaveClearReadStatus();

            }         

        }

       

        if(error_detected == true)

        {

            //HandleError();

        }   

0 Likes
1 Solution

Turns out that the issue was with the master.

View solution in original post

0 Likes
2 Replies
YiZ_31
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi,

How did you set the read buffer? Is it possible to debug with  uart print?

Regards,

Eddie

0 Likes

Turns out that the issue was with the master.

0 Likes