IMXRT1064 I2C (master) with Arduino (slave)

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

IMXRT1064 I2C (master) with Arduino (slave)

跳至解决方案
2,485 次查看
Alberto_isorna
Contributor II

Hello, 

I have a problem while communicating the MIMXRT1064-EVK with an Arduino Uno. 

I imported the example called: lpi2c_edma_b2b_transfer_master

and I'm doing the follwing code in Arduino: 

#include <Wire.h>

# define I2C_SLAVE_ADDRESS 126 // 12 pour l'esclave 2 et ainsi de suite

#define PAYLOAD_SIZE 34

void setup()
{
Wire.begin(I2C_SLAVE_ADDRESS);
Serial.begin(9600);
Serial.println("-------------------------------------I am Slave1");
delay(1000);
Wire.onRequest(requestEvents);
Wire.onReceive(receiveEvents);
}

void loop(){}

int n = 0;

void requestEvents()
{
Serial.println(F("---> recieved request"));
Serial.print(F("sending value : "));
Serial.println(n);
Wire.write(n);
}

void receiveEvents(int numBytes)
{
Serial.println(F("---> recieved events"));
n = Wire.read();
Serial.print(numBytes);
Serial.println(F("bytes recieved"));
Serial.print(F("recieved value : "));
Serial.println(n);
}

 

I can't perform this communication, meanwhile with 2 NXP boards yes. Could you please give me some hints about how to continue??

Best regards, 

Alberto.

0 项奖励
回复
1 解答
2,478 次查看
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @Alberto_isorna,

Since you mention that between two NXP boards this work, I suspect that the communication error is due to some problem in the Arduino code. I suggest being sure that the correct length package is used and give a try using the example without DMA.

Best Regards,

Alexis Andalon

在原帖中查看解决方案

0 项奖励
回复
2 回复数
2,465 次查看
Alberto_isorna
Contributor II

Yes,  the lenght package was the problem.

Find attached both codes that worked for me in Arduino and IMXRT side if you want. 

Best regards, 

Alberto. 

0 项奖励
回复
2,479 次查看
Alexis_A
NXP TechSupport
NXP TechSupport

Hello @Alberto_isorna,

Since you mention that between two NXP boards this work, I suspect that the communication error is due to some problem in the Arduino code. I suggest being sure that the correct length package is used and give a try using the example without DMA.

Best Regards,

Alexis Andalon

0 项奖励
回复