mattairtech / ArduinoCore-samd

This is a fork from arduino/ArduinoCore-samd on GitHub. This will be used to maintain Arduino support for SAM D|L|C (M0+ and M4F) boards including the MattairTech Xeno Mini and the MT-D21E (see https://www.mattairtech.com/). It adds support for new devices like the D51, L21, C21, and D11. It also adds new clock sources, like a high speed crystal or internal oscillator.
103 stars 43 forks source link

Wire.write problem as I2C slave #23

Open alejandroImagina opened 5 years ago

alejandroImagina commented 5 years ago

Hi, I've detected a wired problem with the I2C library.

The SAMD21 acts as a slave and only send one byte as the master requests.

I've found that if the bytes to send is greater than 7F, and it is stored in a variable. The function send FF instead of the correct value.

Example:

uint8_t toSend=0x80;
.
.
.
void OnRequest()
{
    Wire.wirte(toSend);
}

If I change the Wire.write(toSend) to Wire.write(0x80) or Wire.write(0xAB), the byte sent is correct.

I've also tried to change the type of the toSend to unsigned char and to char. And the results were the same.

I'm using the Arduino IDE 1.8.7 and the SAM D|L|C 1.6.18 beta-1

Regards, Alex.