IMXRT1064 I2C (master) with Arduino (slave)

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

IMXRT1064 I2C (master) with Arduino (slave)

ソリューションへジャンプ
1,253件の閲覧回数
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 解決策
1,246件の閲覧回数
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 返答(返信)
1,233件の閲覧回数
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 件の賞賛
1,247件の閲覧回数
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 件の賞賛