Page 1 of 1

Cannot get any HW serial interface working on STM32F407VG Discovery

Posted: Mon Mar 01, 2021 3:07 pm
by Bulek44
Hello,

I'm trying to get at least of one HW U(S)ART interfaces working, but oscilloscope doesn't show anything.

Have tried several different snippets, but not one of them gives any results.
SoftwareSerial object on same pins gives normal output, default Serial object on USB CDC works ok.
But none of HW serial interfaces ...

What am I doing wrong ? PA9 even shows 5V steady on output ?

Thanks, regards.

Code: Select all

//                     RX    TX
//HardwareSerial SerialTest(PB7, PB6);
//HardwareSerial SerialTest(PA10, PA9);
//HardwareSerial SerialTest(PA_10, PA_9);

//#define GPS_UART_TX PA9 
//#define GPS_UART_RX PA10 
//HardwareSerial SerialTest(GPS_UART_RX, GPS_UART_TX); 

//                      RX    TX
HardwareSerial Serial1(PA10, PA9);
 
void setup() {
//  SerialTest.begin(9600); 
  Serial1.begin(9600); 
//  Serial.begin(115200); 
}

void loop() {
//  SerialTest.println("Hello World!");
  Serial1.println("Hello World!");
//  Serial.println("Hello World!");
  
  delay(1000);
}

Re: Cannot get any HW serial interface working on STM32F407VG Discovery

Posted: Mon Mar 01, 2021 3:56 pm
by fredbox
Snippets from one of my projects on a STM32F407 black board:

Code: Select all

#define mySerial SerialUSB
HardwareSerial gpsSerial(PA10, PA9);
in setup()

Code: Select all

  mySerial.begin(9600);
  gpsSerial.begin(9600);
in loop()

Code: Select all

  if (gpsSerial.available())
  {
    char ch = gpsSerial.read();
    mySerial.print(ch);
  }
Options -
USB: CDC enabled, no generic serial
U(S)ART enabled, no generic serial.

Output - prints messages from a GPS module attached to PA9 and PA10 on the USB serial port.

Re: Cannot get any HW serial interface working on STM32F407VG Discovery

Posted: Mon Mar 01, 2021 5:11 pm
by mlundin
Try pins PA2 and PA3, or pD8 and PD9, it looks like PA10 and PA9 are connected to the debug ST-Link

Re: Cannot get any HW serial interface working on STM32F407VG Discovery

Posted: Tue Mar 02, 2021 9:14 am
by fpiSTM
The STLink COM port is not physically connected.
See the User manual:
Image