MPC5748G   I2C driver problem

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC5748G   I2C driver problem

857 Views
huqiang
Contributor IV

Hi everybody!

 

    My I2C project can send and receive successfully (single step mode) , but cannot run by Resume,

it will stuck at "while (I2C_2.IBSR.B.IBB == 1);"

152495_152495.pngpastedImage_4.png

 

    Here's the successful example introduction of the project (single step mode):

    I2C_2 is set as a transmit master node, interrupt enabled, transmit data is 0x55

    I2C_3 is set as a receive slave node, interrupt disabled.

 

    The program data loop is supposed to be as shown in the following picture:

152496_152496.pngpastedImage_5.png.

     Attachment is my program project for reference.

 

     Thanks a lot!

Original Attachment has been moved to: mpc5748g_Z4_1.zip

Labels (1)
Tags (3)
0 Kudos
2 Replies

538 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Use following code for your Slave_Set function. You should check the IBIF flag and also do a dummy read to initiate receive operation. 

void I2C_Slave_Set(void)

{

       uint8_t dummy;

       while (I2C_3.IBSR.B.IBIF == 0);

       I2C_3.IBSR.B.IBIF = 1;

       if (I2C_3.IBSR.B.IAAS == 1)

       {

              if (I2C_3.IBSR.B.SRW == 0)

              {

                     I2C_3.IBCR.B.TXRX = 0;

                     dummy = I2C_3.IBDR.R;

              }

              else

              {

                     I2C_3.IBCR.B.TXRX = 1;

              }

       }

}

BR, Petr

0 Kudos

538 Views
huqiang
Contributor IV

Thank you a lot! I will check the code later.

BR

0 Kudos