i have simple program written for UNO R4 WIFI.
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.write(0x11);
delay(1000);
byte a[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xAA, 0xBB, 0xCC, 0xDD};
Serial.write(a, 8);
delay(1000);
Serial.write(0x22);
delay(1000);
unsigned int b = 0xDDCCBBAA;
Serial.write((byte *) &b, 4);
Serial.write((byte *) &b, 4);
delay(1000);
Serial.write(0x33);
delay(1000);
}
It’s should simple write “11AABBCCDDAABBCCDD22AABBCCDDAABBCCDD33″(hex) into Serial port. But in receiver i got “11AABBCCDDAABBCCDD22AABBCCAABBCCDD33”. So as you can see second try to write unsigned long “overwrites” last 2 bytes from previous one. Do you have any idea why?
I know how to create workaround. I could simple send all data in one write call. But I want to know why this is happening 😀