Hi there,
I'm encountering issues with the serial communication on Arduino R4 Minima.
I have a project, that runs fine on the Arduino R3. This project communicates wit a PC (C# program) via serial port.
I am unable to get it to run on the R4.
It seems, that R4 behaves different than on R3 concerning the serial port. My test program initializes the serial port to a certain baudrate and then changes the baudrates. The test results are:
a) Regardless what baudrate I set initially by the software, Arduino always seems to set the baudrate according to the baudrate in the Serial Monitor. Successive changes to the baudrate seems not to have an effect. (see attached screen shot)
b) I can see the output from the test program only on the Serial Monitor of the Arduino IDE and on the Serial Monitor of MS Visual Studio with VisualMicro extensions. If I use a different Terminal Program, I cannot see the output generated by the R4 test program??
c) I can simulate the serial protocol of my original communication program using Arduino Serial Monitor. This seems to work.
My questions:
q1) What is the trick (or behind the scenes), that the R4 always comminicates with the baudrate that is set in the Serial Monitor?
q2) What do I have to make, that the communication with the PC works?
Thanks for your Help
Michael
Here is my test program:
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(1200);
while (!Serial);
Serial.println("Setup: Set first baudrate: 1200");
Serial.println("Setup: done ...");
}
// the loop function runs over and over again until power down or reset<
void loop() {
doDisplayLoop();
Serial.println("Set new baudrate: 115200");
Serial.end();
Serial.begin(115200);
doDisplayLoop();
Serial.println("Set new baudrate: 19200");
Serial.end();
Serial.begin(19200);
doDisplayLoop();
Serial.println("Set new baudrate: 9600");
Serial.end();
Serial.begin(9600);
doDisplayLoop();
Serial.println("Set new baudrate: 1200");
Serial.end();
Serial.begin(1200);
doDisplayLoop();
Serial.println("Set new baudrate: 300");
Serial.end();
Serial.begin(300);
doDisplayLoop();
}
void doDisplayLoop() {
for (int i = 1; i <= 5; i++) {
PrintSerial();
delay(500);
}
}
void PrintSerial() {
long time = millis();
int Baud = Serial.baud();
int StopBits = Serial.stopbits();
int ParityType = Serial.paritytype();
int NumBits = Serial.numbits();
Serial.print("Time=");
Serial.print(time);
Serial.print(" Baud=");
Serial.print(Baud);
Serial.print(" NumBits=");
Serial.print(NumBits);
Serial.print(" StopBits=");
Serial.print(StopBits);
Serial.print(" ParityType=");
Serial.print(ParityType);
Serial.println();
}

