Possible to use USB serial + other hardware serial at same time?

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
virtual81
Posts: 1
Joined: Mon Jul 18, 2022 3:30 am

Possible to use USB serial + other hardware serial at same time?

Post by virtual81 »

Hi all, new here.

I have a situation where i would like to use the USB serial of a BluePill as well as other serial pins.
I'm using a lib called DCS BIOS that is for bringing flight sim cockpit data (flashing caution light for example) to an Arduino for building a replica cockpit.

Following code works flashing onboard LED PC13 when master caution light flashes in my sim.
Adding the Serial1 parts gives an error when i go to compile..

Code: Select all

#define DCSBIOS_DEFAULT_SERIAL
#include "DcsBios.h"
//                      RX    TX
HardwareSerial Serial1(PB11, PB10);

/* Declare a Master Caution Reset button on pin 10 */
DcsBios::Switch2Pos ufcMasterCaution("UFC_MASTER_CAUTION", 10);
/* Make the LED connected to PC13 into a Master Caution Light */
DcsBios::LED masterCaution(0x1012, 0x0800, 13);
Serial1.println("FLASH");
void setup() {
  DcsBios::setup();
  Serial1.begin(250000);
}

void loop() {
  DcsBios::loop();
}
In the Tools > USB Support menu of the IDE there is mention... "CDC (generic 'Serial' supersede U(S)ART)
What does this mean, and is it relevant?

Would ultimately like to talk to the PC using serial over the USB port and talk to other (Nextion serial display) devices over the other serial ports.

Any suggestions?
Error from compiler...

Code: Select all

MasterCaution:13:1: error: 'Serial1' does not name a type
   13 | Serial1.println("FLASH");
      | ^~~~~~~
ag123
Posts: 1656
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Possible to use USB serial + other hardware serial at same time?

Post by ag123 »

welcome

Serial1.println("FLASH");

should be inside setup() or loop();

do take some time to review the wiki, faqs etc
https://github.com/stm32duino/wiki/wiki
viewtopic.php?f=2&t=301
Post Reply

Return to “General discussion”