I use UART binary communication channel on 33iot. All works fine except transmitting zero byte 0x00. I have read few other threads on related topics and they suggested to include explicit (byte) typing to avoid misinterpretation with null string termination.
However even explicit Serial1.write((byte) 0x00) does not send anything. All other non-zero values are being sent OK.
This is a part of large project that I cannot post here. However I am sure that all other aspects (eg. UART serial connection initialisation, all HW aspects, etc.) are working OK. I was able to isolate the problem to this single code line:
Serial1.write((byte) 0x01) ... works OK and correctly sends the byte
Serial1.write((byte) 0x00) ... does not send anything
the UART communication is between Arduino and other microcontroller (based on xmc4200)
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available())
{
Serial.println("got a byte");
Serial.read();
}
}
prints the "got a byte" message every second as expected
The two Nanos have a common GND connection and the boards are connected by a single wire from the TX1 pin on the 33 to the Rx pin on the classic. I did not bother with a voltage level shifter because of the direction of the transmission from 3V3 to 5V
are you sending binary data or ASCII? ASCII char strings are by convention terminated with a NUL, 0x0
something that delimits the start and end of binary data is required such as start and end values. those values need to be escaped if sent as data, usually by preceding them with an escape value, which also needs to be escaped when sent as data