Cannot get any HW serial interface working on STM32F407VG Discovery

Post here first, or if you can't find a relevant section!
Post Reply
Bulek44
Posts: 16
Joined: Mon Feb 22, 2021 3:42 pm

Cannot get any HW serial interface working on STM32F407VG Discovery

Post 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);
}
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

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

Post 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.
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

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

Post by mlundin »

Try pins PA2 and PA3, or pD8 and PD9, it looks like PA10 and PA9 are connected to the debug ST-Link
User avatar
fpiSTM
Posts: 1756
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

The STLink COM port is not physically connected.
See the User manual:
Image
Post Reply

Return to “General discussion”