Skip to content

SoftwareSerial sets pinMode in its constructor which is too soon #3041

Closed
@nickgammon

Description

@nickgammon

In version 1.6.0 (at least) of the IDE the constructor for SoftwareSerial does this:

  setTX(transmitPin);
  setRX(receivePin);

setTX does this:

  pinMode(tx, OUTPUT);
  digitalWrite(tx, _inverse_logic ? LOW : HIGH);

This is not an appropriate time to be doing pinMode or digitalWrite because init() has not been called yet. Who knows what init will do with pins? It might set them all to inputs, for example.

Metadata

Metadata

Assignees

Labels

Component: CoreRelated to the code for the standard Arduino APILibrary: SoftwareSerialThe SoftwareSerial Arduino library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions