MPC5748G   I2C driver problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MPC5748G   I2C driver problem

1,194件の閲覧回数
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

ラベル(1)
タグ(3)
0 件の賞賛
2 返答(返信)

875件の閲覧回数
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 件の賞賛

875件の閲覧回数
huqiang
Contributor IV

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

BR

0 件の賞賛