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
What if you try changing the value of the bytes to printable characters? I simulated it in wokwi on ESP32 and RP2040 (both 32-bit) and your problem does not appear.
Hopefully it is not something particular to the RA4M1.
Sorry, my knowledge is from a year or so ago, when I debugged and had a PR to update a lot of the Hardware Serial code base... I have since then closed the PR out, as I know another member also did some updates using DMA...
Back then there was an issue, that
Serial.write((byte *) &b, 4);
Would return as soon as the last character was placed into the hardware output register.
And then then the second call:
Serial.write((byte *) &b, 4);
DId not check to see if the output register was empty yet, but would blindly stuff the
first character of your new output into the output register and if it was not empty
you just lost the last character of your previous write.
But again this was a year or so ago. Hopefully some of this has been addressed since then.
Tanks you all for your help. KurtE I think I even found your PR in githubs but it seems like there are still some issues in core library. I'm using the newest 1.2.0 version and the problem is there.
Interestingly MaximoEsfuerzo was right if I use Serial.write((char*) &b, 4);
Problem disappear.
Due to user issues with Arduino R4 using our product the IO Expander, I've rewritten the UART driver that has a properly working Tx buffer, fixed the ring buffer that is not interrupt safe, and got both Serial and Serial1 working full duplex at the same time. I'm looking for testers please contact me at my site. Once tested I plan on releasing it for free. Here's a video of both ports working at the same time at 115k; http://www.zevendevelopment.com/videos/IOExpanderArduinoR4WorkingWithBothSerialPorts.mp4