Description
Describe the bug
SoftwareSerial seems to cause program execution to freeze at startup when using certain pins.
So far in my testing it looks like the freeze happens if:
- Pins are specified using the Ax analog naming convention, or
- The PYn convention is used with pins that map to an Ax convention in variant.h
The freeze only seems to happen when both pins meet the above - if one maps to an analog pin and the other does not, the freeze does not happen.
Results are consistent on both 1.9.0 and current master branch. I am testing with a RUMBA32 board which is the only STM32 board I have to hand at the moment, but I can try to round up a different dev board shortly.
Is SoftwareSerial expected to work when using the Ax & PYn pin naming conventions?
To Reproduce
I am testing with the following sketch:
#include <SoftwareSerial.h>
#define PIN_SS_RX PA3
#define PIN_SS_TX PA4
SoftwareSerial mySerial(PIN_SS_RX, PIN_SS_TX);
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
With the pin pairs that seem to cause a 'freeze', the LED does not blink. I've tested with the following pin pairs.
These work (LED blinks / sketch runs):
// Two analog - one using PYn, the other digital pin number
#define PIN_SS_RX 3
#define PIN_SS_TX PA4
// Two analog - one using PYn, the other digital pin number
#define PIN_SS_RX PA3
#define PIN_SS_TX 4
// Two analog - one using PYn, the other digital pin number
#define PIN_SS_RX 4
#define PIN_SS_TX PA3
// Two analog - one using PYn, the other digital pin number
#define PIN_SS_RX PA4
#define PIN_SS_TX 3
// Two non-analog - both using PYn
#define PIN_SS_RX PA8
#define PIN_SS_TX PA9
// Two analog - one using PYn, the other digital pin number
#define PIN_SS_RX 4
#define PIN_SS_TX PB0
// One analog, one digital, both using PYn
#define PIN_SS_RX PA8
#define PIN_SS_TX PB0
// One analog using Ax, one digital using PYn
#define PIN_SS_RX A0
#define PIN_SS_TX D4
These do not work (no LED blinking):
// Two analog - both using PYn
#define PIN_SS_RX PA3
#define PIN_SS_TX PA4
// Two analog - both using PYn (swapped)
#define PIN_SS_RX PA4
#define PIN_SS_TX PA3
// Two analog - both using PYn (non-adjacent pins)
#define PIN_SS_RX PA4
#define PIN_SS_TX PB0
// Two analog - both using Ax
#define PIN_SS_RX A0
#define PIN_SS_TX A1
// Two analog - both using Ax (different pins just in case)
#define PIN_SS_RX A5
#define PIN_SS_TX A6
These particular pins as described in the RUMBA32 variant.h:
#define PA3 A0 //D3
#define PA4 A1 //D4
#define PA8 8 //D8
#define PA9 9 //D9
#define PB0 A13 //D16
#define PC3 A5 //D35
#define PC4 A6 //D36
Steps to reproduce the behavior:
- Try the above sketch with two analog pins (try Ax naming convention, and PYn, etc.)
- Check if the LED blinks?
Expected behavior
Program should not freeze / should execute as expected when using these pins.
Desktop (please complete the following information):
- OS: Windows
- Arduino IDE version: 1.8.12 and 1.9.0-beta
- STM32 core version: 1.9.0 and master branch (f190402)
- Tools menu settings if not the default: USART: Enabled (Generic 'Serial'), USB: CDC (Generic 'Serial')
- Upload method: STM32CubeProgrammer DFU
Board (please complete the following information):
- Name: RUMBA32
- Hardware Revision: Rev 1.0D
Additional context
I noticed this during testing of the SERIAL_TIMER as part of PR #1092