Serial monitor

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Serial monitor

Post by mebab »

I have developed an stm32L based application using Arduino IDE. I need to debug the code. How to define USART2 (RX, TX) to communicate via a USB-TTL converter?

Thanks for your kind help
by GonzoG » Sat Jan 22, 2022 10:27 pm
1. your USB-TTL adapter might be faulty
2. you have wrong driver for your adapter
3. there is a program on your PC that connects automatically to any available COM port.
Go to full post
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: Serial monitor

Post by GonzoG »

Just define HardwareSerial object and use it same as "standard" Serial (eg. Serial1.write(), Serial1.print())
https://github.com/stm32duino/wiki/wiki ... wareserial
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Serial monitor

Post by mebab »

Thanks a lot, Gozog!

I did as you mentioned in a simple code for STM32L433 as follows:

Code: Select all

//                      RX    TX
HardwareSerial Serial2(PA15, PA2);

void setup() {
  Serial2.begin(115200); 
}

void loop() {
  Serial2.println("Hello World!");
  delay(1000);
}
However, I receive the following error message:

Code: Select all

Error opening serial port 'COM21'. (Port busy)
What is the reason for the port to be busy?
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: Serial monitor

Post by GonzoG »

It's exactly what it's written there: "Port busy" - something is using it.
And it has nothing to do with MCU. This COM port is your USB-TTL adapter.
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Serial monitor

Post by mebab »

I have nothing else than the USB-TTL adapter which is connected to the following pins on my board:

Code: Select all

3.3V
GND
TX-->RX2 or TX2
RX-->TX2 or RX2
When I change the port number via 'Device manager', I still receive a similar error with the new port number!
what might be the solution? changing the port number to any specific one or what?
I even closed Arduino IDE and used putty to see if it helps to bypass the port busy issue. But it didn't help. There is nothing else left to close or disconnect!
As you mentioned, USB-TTL is using the same port number. On the other hand, we use this device to see the same serial port. It is confusing to know what to do.
Last edited by mebab on Sat Jan 22, 2022 9:45 pm, edited 1 time in total.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: Serial monitor

Post by GonzoG »

The COM port you see on your computer has nothing to do with your STM board.
It's an USB-TTL adapter and computer connects with this adapter, not MCU.

If you cannot open COM port, then something on your PC is using this port.
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Serial monitor

Post by mebab »

Sorry! I changed the port number of the USB-TTL adapter to many others via 'Device manager'. However, it didn't help. Whatever free port number I assign, is represented busy by Arduino IDE or Putty. I don't know what is left to do!
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: Serial monitor

Post by GonzoG »

1. your USB-TTL adapter might be faulty
2. you have wrong driver for your adapter
3. there is a program on your PC that connects automatically to any available COM port.
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Serial monitor

Post by mebab »

Thank you GonzoG!

I updated the firmware of the USB-TTL adapter and the problem is solved now.

Thanks again,
Mehrdad
Post Reply

Return to “IDE's”