Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with Serial + Hardware Serial when using different baud rates #55

Closed
CiprianFlorin-Ifrim opened this issue Apr 17, 2022 · 4 comments · May be fixed by arduino/ArduinoCore-mbed#471
Closed
Labels
topic: documentation Related to documentation for the project type: support OT: Request for help using the project

Comments

@CiprianFlorin-Ifrim
Copy link

CiprianFlorin-Ifrim commented Apr 17, 2022

Description of defect

If I intitialize Serial.begin(115200) and hardware Serial1.begin(115200), both work.
If I initialize Serial.begin(9600) and hardware Serial1.begin(9600), both work.
If, however, I initialize Serial.begin(115200) and hardware Serial1.begin(9600), the whole code freezes.

Moreover, the battery bug fix solved in 3.0.0 is still persisting with UART.

Target(s) affected by this defect ?

Nicla Sense ME

Toolchain(s) (name and version) displaying this defect ?

Mbed OS Nicla Boards 3.0.1
Latest bootloader
Arduino 1.8.16

What version of Mbed-os are you using (tag or sha) ?

mbed-os-3.0.1

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Mbed OS Nicla Boards 3.0.1
Latest bootloader available in the Nicla FW repo
Arduino 1.8.16

How is this defect reproduced ?

Simple example code:

#include <Arduino.h>
#include "Nicla_System.h"

void setup()
{
  nicla::begin();
  Serial.begin(115200);
  Serial1.begin(9600);

  delay(1000);
}

void loop() {
  while(Serial.available()) {
    char incomingCharacter = Serial.read();
    if (incomingCharacter == '1') {
      Serial.println("Command activated");
    }
    delay(100);                   
  }
}
@facchinm
Copy link
Member

Hi @CiprianFlorin-Ifrim ,
in Nicla Sense Serial and Serial1 are indeed the same object (and the same couple of pins) due to how serial ports are defined in the core (see here https://github.com/arduino/ArduinoCore-mbed/blob/master/cores/arduino/Arduino.h#L108-L110 ).
Moreover, we can't instantiate two different serials since the onboard nRF52832 only has one hardware UART instance.

Maybe it would be less confusing for the end user to undefine Serial1 object if only one UART is available. @per1234 @sebromero what do you think about that?

@facchinm facchinm added topic: documentation Related to documentation for the project type: support OT: Request for help using the project labels Apr 19, 2022
@per1234
Copy link
Contributor

per1234 commented Apr 19, 2022

Maybe it would be less confusing for the end user to undefine Serial1 object if only one UART is available.

Yes. I said the same back during the discussion that somehow resulted in that code being added:

arduino/ArduinoCore-mbed#54 (comment)

@CiprianFlorin-Ifrim
Copy link
Author

CiprianFlorin-Ifrim commented Apr 20, 2022

Thank you for the replies. I was not aware it was the same hardware serial and spent a few good hours on my main code thinking I had some issues there.

I think it would be good to add in the Cheat Sheet that they are the same and same baur rate should be set for both: https://docs.arduino.cc/tutorials/nicla-sense-me/cheat-sheet#uart

Leaving that aside, have you checked "Moreover, the battery bug fix solved in 3.0.0 is still persisting with UART.".
I still cannot run the code off the battery without having the USB first. I do not know if it is an I2C issue or UART issue. But it works with a simple code, and doesn't with the protocols started.

@sebromero
Copy link
Contributor

Maybe it would be less confusing for the end user to undefine Serial1 object if only one UART is available. @per1234 @sebromero what do you think about that?

@per1234 @facchinm Agree, I think it would be less confusing. Let's do it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: documentation Related to documentation for the project type: support OT: Request for help using the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants