Page 1 of 1

Serial1 usage

Posted: Mon Oct 04, 2021 7:26 pm
by RolfSte
Hi,

I'm using an NUCLEO F103 board and try to send monitor data over Serial1.

This works in setup:

Code: Select all

void setup() {
	HardwareSerial Serial1(PA10, PA9);
	Serial1.begin(9600);
        Serial1.println("Testpoint 1");
       ......
but I have found no way to use Serial1 in other functions
or globally for classes in other files.

Re: Serial1 usage

Posted: Mon Oct 04, 2021 7:54 pm
by fpiSTM
You have to define the Serial1 outside the setup function to be global else it is local at the function.

Code: Select all

HardwareSerial Serial1(PA10, PA9);

void setup() {
        Serial1.begin(9600);
        Serial1.println("Testpoint 1");
}