Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoftwareSerial Freezes on Certain Pins (Analog?) #1093

Closed
chrissbarr opened this issue Jun 10, 2020 · 2 comments · Fixed by #1094
Closed

SoftwareSerial Freezes on Certain Pins (Analog?) #1093

chrissbarr opened this issue Jun 10, 2020 · 2 comments · Fixed by #1094

Comments

@chrissbarr
Copy link
Contributor

chrissbarr commented Jun 10, 2020

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:

  1. Try the above sketch with two analog pins (try Ax naming convention, and PYn, etc.)
  2. 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

@fpistm
Copy link
Member

fpistm commented Jun 10, 2020

Hi @chrissbarr
seems strange.

Is SoftwareSerial expected to work when using the Ax & PYn pin naming conventions?

Yes it should anyway after testing with a Nucelo_F411RE I've got the same issue.
We will investigate that.

@chrissbarr
Copy link
Contributor Author

Hi @fpistm,

Yes it should anyway after testing with a Nucelo_F411RE I've got the same issue.

Well, I'm glad it's not just me - thought I was going crazy...

Thanks for trying this so quickly.

fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Jun 10, 2020
Fix stm32duino#1093

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
fpistm added a commit that referenced this issue Jun 10, 2020
Fix #1093

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants