Hello all,
Thanks for taking the time to read my post. I'm the owner of Arduino UNO, NANO and MEGA. In this moment I wanted to start with Arduino DUE. Its specifications are promising, but its support is poor. I even seen official examples with errors or missing information. Anyway... after buy it, i startet researching to use this arduino, fixing and adapting codes to start to make functional my old projects in "DUE".
There is a particular one with "I2C", it is already working on my other Arduinos. I adapt it to the new environment with its "pullups" at 3.3V, but it does not work: I can't read the information it gives my slave device. The curious thing is that my device do actions by "I2C" but no answer to me. The code I use to ask to my device is the follow:
#include <Wire.h>
const int NCVaddr=0x60;
byte recived[7];
byte byteRX;
void setup()
{
//Connections:
Serial.begin(9600);
Wire.begin();
Wire.setClock(400000); // 400000 Fast Mode.
//Initial Message:
Serial.println("READY!");
delay(500);
}
void loop()
{
//ADDRESS
Wire.beginTransmission(NCVaddr);
//2 ADDRESS
Wire.write(0xC0);
//IDENTIFIER (REGISTER)
Wire.write(0x0A);
//CLOSE TRANSMISION
Wire.endTransmission(false);
//REQUEST FOR DATA
Wire.requestFrom(NCVaddr,5,true);
byte c=0;
while(Wire.available()) // Returns the number of bytes available. So Slave may send less than requested...
{
recived[c] = Wire.read(); // Receive a byte
c++;
}
Serial.println("Bytes Received: " + String(byteRX));
delay(2000);
for(int i=0;i<byteRX;i++)
{
Serial.println("Byte " + String(i+1));
Serial.println(recived[i], HEX); //Print bytes
}
delay(2000);
}
As I said, this code works perfect in my other Arduinos. I checked the I2C signal in my oscilloscope comparing the signals between the code with Arduino UNO (wich works) and the code with Arduino DUE and I saw a little difference whe the "Wire.requestFrom()" runs itself: The frame what this code should output by I2C is: 0x60=1100000, the read bit=1, and finally the ACK=0; all the frame looks like: 110000010. BUT, in the Arduino DUE case at the end of this frame I have a NACK or 1 looking like: 110000011, and I don't know why.
The acknowledge bit allows the receiver to signal the transmitter that the byte was successfully received and another byte may be sent. So, when SDA remains HIGH during this ninth clock pulse, this is defined as the Not Acknowledge signal. of course because an error has ocurred. But why it only Happen with DUE? Any ideas?
Thanks!!
