Softwareserial issue on stm32 f411re

All about boards manufactured by ST
Post Reply
DonGorgon
Posts: 1
Joined: Sat Jun 20, 2020 11:17 am

Softwareserial issue on stm32 f411re

Post by DonGorgon »

Hello everyone,

I got a shield for arduino uno. There are 2 UART devices on this shield .
On arduino uno everything work fine. So i decide to install my shield on nucleo64 board.
my nucleo is equipped with stm32 f411re core. i'm using stm32duino api.

And here occure an issue. UARt devices doesn't work together.
When i run them separtly (only one is initialized) they work fine.

I can't use HardwareSerial, cause they are not connected to hardwareserial pins.

I tried also used "Serial.listen()" function but it doesnt help.

Are there any limitations due to softwareserial on stm32duino compare to normal arduino?
Or i miss something ?

Thanks in advance for any help,
ABOSTM
Posts: 60
Joined: Wed Jan 08, 2020 8:40 am
Answers: 7

Re: Softwareserial issue on stm32 f411re

Post by ABOSTM »

Hi @DonGorgon,
The PullRequest provides some informations about softwareSerial implementation.
https://github.com/stm32duino/Arduino_C ... 2/pull/645

As you can see, yes there is a limitation:
baudrate max 57600 with 80MHzh MCU frequency. And this is for a single SoftwareSerial.
Nevertheless,the good new is that example 'TwoPortReceive' used to work well. Please note that baudrate for this example is 9600.

So I would advice you to decrease baudrate as much as possible.
And try to start from 'TwoPortReceive' example and adapt it to your shield.
Try to simplified your sketch to the minimum: keep only Software serial (to avoid being disturbed by other stuff, specially around interrupt treatment) and check whether it is still failed.

If still failed, can you provide more information on your setup:
* which baurate are you using for both devices ?
* which shield are you using ?
* how devices are working (asynchronous data sending to MCU or only on request from the MCU ...)?
* You may share your sketch (simplified to keep only software serial and confirmed it is still failed )
* describe a bit more how it fails: only 1 device doesn't work ? or both ? are data corrupted or you never get data ? ...
User avatar
konczakp
Posts: 18
Joined: Sat Jul 25, 2020 8:22 pm

Re: Softwareserial issue on stm32 f411re

Post by konczakp »

I have the same problem on BlackPill stm32f411eu. I have downloaded newest Arduino IDE (1.8.13) and made a clean install stm32 boards (1.9.0) from board manager (with a portable folder). Even the simplest code is not working

Code: Select all


#include <SoftwareSerial.h>

SoftwareSerial mySerial(PB1, PB0);

void setup() {
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() { 
  mySerial.println("BLINK");
  
}
Same problem was on 1.8.9 Arduino IDE version. There used to be a SoftwareSerialCC which was working on Maple Mini but it seams that this one is also not working or I don't know what to change. Is there any fix or workaround? I have plenty of stuff working on USART and really need the softwareserial to work
roboticboyer
Posts: 4
Joined: Sun Jun 07, 2020 6:29 pm

Re: Softwareserial issue on stm32 f411re

Post by roboticboyer »

I suggest to use the hardware serials https://github.com/stm32duino/wiki/wiki ... wareserial of the F411, not the software serial as done for Arduino Uno

See the pin map:

Image
User avatar
konczakp
Posts: 18
Joined: Sat Jul 25, 2020 8:22 pm

Re: Softwareserial issue on stm32 f411re

Post by konczakp »

As I mentioned before I have more USART hardware then USART ports on stm32f4 (USART1,USART2 and USART6 is not enough for me). So I need to get the software serial running - it can be anything like SoftwarSerial, NewSoftwareSerial, SoftwareSerialCC etc
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: Softwareserial issue on stm32 f411re

Post by fredbox »

I tested a GPS module connected to PB0/PB1 with SoftwareSerial on a 407 board.

It is working fine, printing the NMEA messages from the module.

Code: Select all

#include <SoftwareSerial.h>
#define mySerial SerialUSB
SoftwareSerial gpsSerial(PB1,PB0);
void setup() {
  mySerial.begin(9600);
  gpsSerial.begin(9600);
}
void loop() {
  if (gpsSerial.available()) {
    char ch = gpsSerial.read();
    mySerial.print(ch);
  }
}
User avatar
konczakp
Posts: 18
Joined: Sat Jul 25, 2020 8:22 pm

Re: Softwareserial issue on stm32 f411re

Post by konczakp »

I copy paste Your code and still the same. No communication. BTW I'm using USB to TTL for USART communication on pins PB0 and PB1 so I'm sure the USB to TTL is working because it is working on hardware serials.
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: Softwareserial issue on stm32 f411re

Post by fredbox »

Jumper PB0 to PB1.

Code: Select all

#include <SoftwareSerial.h>
#define mySerial SerialUSB
SoftwareSerial swSerial(PB1, PB0);
void setup() {
  mySerial.begin(9600);
  swSerial.begin(9600);
}
void loop() {
  for (int i = 0; i < 6; ++i) {
    swSerial.print("hello\n"[i]);
    if (swSerial.available()) {
      char ch = swSerial.read();
      mySerial.print(ch);
    }
  }
}
This repeatedly prints hello on the SerialUSB. Remove the jumper and it stops.
User avatar
konczakp
Posts: 18
Joined: Sat Jul 25, 2020 8:22 pm

Re: Softwareserial issue on stm32 f411re

Post by konczakp »

Unfortunately it doesn't print anything. Setting jumper between PB0 and PB1
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”