Page 1 of 1

Softwareserial issue on stm32 f411re

Posted: Tue Jun 23, 2020 5:51 pm
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,

Re: Softwareserial issue on stm32 f411re

Posted: Wed Jun 24, 2020 7:58 am
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 ? ...

Re: Softwareserial issue on stm32 f411re

Posted: Sat Jul 25, 2020 8:34 pm
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

Re: Softwareserial issue on stm32 f411re

Posted: Sun Jul 26, 2020 2:05 pm
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

Re: Softwareserial issue on stm32 f411re

Posted: Sun Jul 26, 2020 5:07 pm
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

Re: Softwareserial issue on stm32 f411re

Posted: Sun Jul 26, 2020 6:34 pm
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);
  }
}

Re: Softwareserial issue on stm32 f411re

Posted: Sun Jul 26, 2020 6:58 pm
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.

Re: Softwareserial issue on stm32 f411re

Posted: Sun Jul 26, 2020 8:13 pm
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.

Re: Softwareserial issue on stm32 f411re

Posted: Sun Jul 26, 2020 8:33 pm
by konczakp
Unfortunately it doesn't print anything. Setting jumper between PB0 and PB1