How to use I2c

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use I2c

1,515 Views
jikehe
Contributor II

volatile bool DataReceivedFlg = FALSE;

volatile bool DataTransmittedFlg = FALSE;

uint8_t OutData[4] = {0x00U, 0x01U, 0x02U, 0x03U};

uint8_t InpData[4];

LDD_TError Error;

LDD_TDeviceData *MyI2CPtr;

int main(void)

{

  PE_low_level_init();

  MyI2CPtr = I2C2_Init(NULL);

  while(1)     

  {

    Error = I2C2_SlaveReceiveBlock(MyI2CPtr, &InpData, 4U);

    if(TRUE == DataReceivedFlg)

    {

        I2C2_SendAcknowledge(MyI2CPtr, LDD_I2C_ACK_BYTE);

        DataReceivedFlg = FALSE;

    }

  }

}

8403_8403.pngpastedImage_3.png

no ack signal

Labels (1)
0 Kudos
4 Replies

752 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

I am sorry , I can't understand your problem clearly.

Can you describe the problem clearly?

Do you want find where you can enable "I2C2_SendAcknowledge" function in CodeWarrior with PE?

0 Kudos

752 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Do you want send NACK signal?

I2C2_SendAcknowledge(MyI2CPtr, LDD_I2C_NACK_BYTE);

NACK PE.jpg

752 Views
jikehe
Contributor II

I use mk10dx256vlq10 mcu, I use codewarrior 10.4 tool, I2C_LDD component Settings->Mode selection selected SLAVE.


volatile bool DataReceivedFlg = FALSE;

volatile bool DataTransmittedFlg = FALSE;

uint8_t OutData[4] = {0x00U, 0x01U, 0x02U, 0x03U};

uint8_t InpData[4];

LDD_TError Error;

LDD_TDeviceData *MyI2CPtr;

int main(void)

{

  PE_low_level_init();

  MyI2CPtr = I2C2_Init(NULL);

  while(1)     

  {

    Error = I2C2_SlaveReceiveBlock(MyI2CPtr, &InpData, 4U);

    if(TRUE == DataReceivedFlg)

    {

        I2C2_SendAcknowledge(MyI2CPtr, LDD_I2C_ACK_BYTE);

        DataReceivedFlg = FALSE;

    }

  }

}

8403_8403.pngpastedImage_3.png

no ack signal

0 Kudos

752 Views
perlam_i_au
Senior Contributor I

Here you can find different Application notes for use I2C, could you be a bit specific about what are you trying to do? or at least could you mention an error or problem, I could search specific solutions, with more information.

Please tell me if this is useful. :smileygrin:

0 Kudos