This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C Loopback Not Working



Hi,

Lets see if someone can help me with this.


I Can't get the I2c Loopback working..

I intialize the I2C with the following configuration:

    /** - set i2c mode */
    i2cREG1->MDR =   (uint32)((uint32)0U << 15U)            /* nack mode                         */           
                   | (uint32)((uint32)1U << 14U)            /* free running                      */           
                   | (uint32)(0U)                           /* start condition - master only     */    
                   | (uint32)((uint32)0U <<11U)             /* stop condition                    */ 
                   | (uint32)((uint32)0U <<10U)             /* Master/Slave mode                 */ 
                   | (uint32)((uint32)I2C_TRANSMITTER)      /* Transmitter/receiver              */ 
                   | (uint32)((uint32)I2C_10BIT_AMODE)      /* xpanded address                   */ 
                   | (uint32)((uint32)0U << 7U)             /* repeat mode                       */ 
                   | (uint32)((uint32)1U << 6U)             /* digital loop back                  */
                   | (uint32)((uint32)0U << 4U)             /* start byte - master only          */ 
                   | (uint32)(1U << 3U)                     /* free data format                  */ 
                   | (uint32)(I2C_8_BIT);                   /* bit count                         */ 

But when I look in the registers I can see the "H" in the send buffer (DXR) but the receive (DRR) is empty!

I've tried to force it using 

i2cREG1->DRR = i2cREG1->DXR;   

But the DRR keeps being empty...

Im using a RM48L952HDK.

Any idea about why this can be happening?

  • Hello:

    We have received your post and we will get back to you soon.

    Regards.

  • Hi, there.

    You can use the following code snip as an example for run I2C in digital loopback mode.

     while(Count--)
      {
      I2C0_Ptr->DXR_UN.DXR_ST.datatx_B8 = *TxData;  // data to transmit to Select Destination Register
      I2C0_Ptr->MDR_UN.MDR_ST.stt_B1    = 1;            // Start the transmission

      while(delay--);
      delay = 1000;
     
      *RxData = I2C0_Ptr->DRR_UN.DRR_ST.datarx_B8;                    // Read incoming data and store in array 

      *TxData++;
      *RxData++;
      };

    To send data over loopback path, you will need to set the start flag after writing to the transmit data rgister.

    Thanks and regards,

    Zhaohong