With the lower speed null char is interpreted as a break.
This works and give a break to the host computer but I noticed two problems.
After the break the Arduino UART is more or less crazy and I have to reboot the Nano to get it working well again...
Also the successive Serial.end. Serial begin etc... seems to cause swing on the TX line and this is badly interpreted as a character (ascii code 120 decimal) by the host computer.
For the same ascii code the signal on tx pin is different before and after the break.
I use 1200 baud 7N2 so the serial monitor of arduino is not working. I use Gtkterm and can see also the problem that way. After the break the ascii code received are not the good one.
BreakPin is set to 5 and as input in setup part of the code.
This produce the expected signal on serial line whithout extra character (one problem solved !).
But again the uart is not working after the break. I can see on scope that for the same keystroke the signal is different on the serial line before and after the break.
A simple reset of the Nano and works well again...
At this moment I dont understand how this is possible ???!
I dont understand except if some kind of "readings" are do by serial functions on the tx pin ???
This is how I had implemented sending a Serial breakfield on one of my projects:
void send_brk(HardwareSerial &refSer, unsigned long baud)
{
//breakfield mode
refSer.end();
refSer.begin(baud);
refSer.write(0x00);
refSer.end();
//normal mode
refSer.begin(baud);
}
void setup() {
unsigned long break_baud = 9600; //baud rate calculated from duration of brk_field;
//break_baud = (duration of brk_field)/9, (9 = 8bits+1 start bit)
Serial.begin(115200);
delay(10);
Serial.println("READY");
delay(5000);
send_brk(Serial, break_baud);
delay(1000);
Serial.println("Finish");
}
void loop() {
// put your main code here, to run repeatedly:
}
I had to add an external pullup-resistor on the TX line to maintain the line voltage as the line would momentarily drop between .end() and .begin() commands.