How to use I2c

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to use I2c

4,876 次查看
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

标签 (1)
0 项奖励
回复
4 回复数

4,113 次查看
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 项奖励
回复

4,113 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Do you want send NACK signal?

I2C2_SendAcknowledge(MyI2CPtr, LDD_I2C_NACK_BYTE);

NACK PE.jpg

4,113 次查看
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 项奖励
回复

4,111 次查看
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 项奖励
回复