IMXRT1064 I2C (master) with Arduino (slave)

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

IMXRT1064 I2C (master) with Arduino (slave)

Jump to solution
1,195 Views
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 Kudos
1 Solution
1,188 Views
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

View solution in original post

0 Kudos
2 Replies
1,175 Views
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 Kudos
1,189 Views
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 Kudos