Skip to content

No support of UART2 & 3 in Version 1.8.0 <-- https://github.com/stm32duino/wiki/wiki/API#hardwareserial #966

@karstengit

Description

@karstengit

Maybe this is only an stupid beginner problem?

This sketch only compile with UART 1 when Serial2 and Serial3 is commented out.

/*
 * Blink without delay and UART Test
*/
#include <HardwareSerial.h>

// Variables:
int previousMillis = 0;        // will store the last time the LED was updated
int interval = 500;            // interval at which to blink (in milliseconds)
uint32_t counter = 0;

void setup() {
	// Set up the built-in LED pin as output:
	pinMode(PC13, OUTPUT);
	
	Serial1.begin(19200);
	Serial2.begin(19200);
	Serial3.begin(19200);
}

void loop() {
	if (millis() - previousMillis > interval) {
		// Save the last time you blinked the LED
		previousMillis = millis();

		Serial1.print("Counter: ");
		Serial1.print(counter);
		Serial1.println(" - Hello UART 1!");

		Serial2.print("Counter: ");
		Serial2.print(counter);
		Serial2.println(" - Hello UART 2!");

		Serial3.print("Counter: ");
		Serial3.print(counter);
		Serial3.println(" - Hello UART 3!");

		counter ++;
		// If the LED is off, turn it on, and vice-versa:
		digitalWrite(PC13,!digitalRead(PC13));
    }
}

You get this Errors:

.../arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino_build_908948/sketch/Blink-Hello.ino.cpp.o: in function `setup':
Blink-Hello.ino.cpp:(.text.setup+0x38): undefined reference to `Serial2'
.../arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: Blink-Hello.ino.cpp:(.text.setup+0x3c): undefined reference to `Serial3'
.../arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /tmp/arduino_build_908948/sketch/Blink-Hello.ino.cpp.o: in function `loop':
Blink-Hello.ino.cpp:(.text.loop+0xa0): undefined reference to `Serial2'
.../arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: Blink-Hello.ino.cpp:(.text.loop+0xa8): undefined reference to `Serial3'
collect2: error: ld returned 1 exit status

But in HardwareSerial.h they are defined:

extern HardwareSerial Serial1;
extern HardwareSerial Serial2;
extern HardwareSerial Serial3;
extern HardwareSerial Serial4;
extern HardwareSerial Serial5;
extern HardwareSerial Serial6;
extern HardwareSerial Serial7;
extern HardwareSerial Serial8;
extern HardwareSerial Serial9;
extern HardwareSerial Serial10;
extern HardwareSerial SerialLP1;

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem rightquestion ❓Usually converted as a discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions