If you build the code below from “Arduino IDE”, it works well.
However, if you build using PlatformIO, an error appears.
Development environment. : Platformio.ini
[env:nrf52840_lora]
platform = nordicnrf52
board = adafruit_feather_nrf52840
framework = arduino
Arduino IDE
https://www.adafruit.com/package_adafruit_index.json
#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 11); // RX, TX
SoftwareSerial mySerial1(9, 10); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
while ( !Serial ) delay(10); // for nrf52840 with native usb
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(115200);
mySerial.println("Hello, world?");
mySerial1.begin(115200);
mySerial1.println("Hello, world?");
}
void loop() // run over and over//
{
/*
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
*/
mySerial.println("Hello Serial 1");
mySerial1.println("Hello Serial 2");
Serial.println("Hello Serial 0!");
delay(100);
}
Error Coce
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:285:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
^~~~~
Archiving .pio\build\nrf52840_dk\libFrameworkArduinoVariant.a
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp: In member function 'bool SoftwareSerial::listen()':
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:341:23: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:341:23: note: suggested alternative: 'AREF'
uint8_t oldSREG = SREG;
^~~~
AREF
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:342:5: error: 'cli' was not declared in this scope
cli();
^~~
In file included from .pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:43:0:
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setTX(uint8_t)':
C:\Users\fishi\.platformio\packages\framework-arduinoadafruitnrf52\cores\nRF5/Arduino.h:138:67: error: invalid conversion from 'NRF_GPIO_Type*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P) ( (g_ADigitalPinMap[P] < 32) ? NRF_P0 : NRF_P1 )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:517:18: note: in expansion of macro 'digitalPinToPort'
uint8_t port = digitalPinToPort(tx);
^~~~~~~~~~~~~~~~
C:\Users\fishi\.platformio\packages\framework-arduinoadafruitnrf52\cores\nRF5/Arduino.h:148:44: error: base operand of '->' is not a pointer
#define portOutputRegister(port) ( &(port->OUT) )
^
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:518:27: note: in expansion of macro 'portOutputRegister'
_transmitPortRegister = portOutputRegister(port);
^~~~~~~~~~~~~~~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setRX(uint8_t)':
C:\Users\fishi\.platformio\packages\framework-arduinoadafruitnrf52\cores\nRF5/Arduino.h:138:67: error: invalid conversion from 'NRF_GPIO_Type*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P) ( (g_ADigitalPinMap[P] < 32) ? NRF_P0 : NRF_P1 )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:528:18: note: in expansion of macro 'digitalPinToPort'
uint8_t port = digitalPinToPort(rx);
^~~~~~~~~~~~~~~~
C:\Users\fishi\.platformio\packages\framework-arduinoadafruitnrf52\cores\nRF5/Arduino.h:149:65: error: base operand of '->' is not a pointer
#define portInputRegister(port) ( (volatile uint32_t*) &(port->IN) )
^
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:529:26: note: in expansion of macro 'portInputRegister'
_receivePortRegister = portInputRegister(port);
^~~~~~~~~~~~~~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:540:31: error: 'table' was not declared in this scope
for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)
^~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:540:31: note: suggested alternative: 'tanl'
for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)
^~~~~
tanl
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:556:9: error: 'digitalPinToPCICR' was not declared in this scope
if (digitalPinToPCICR(_receivePin))
^~~~~~~~~~~~~~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:556:9: note: suggested alternative: 'digitalPinToPort'
if (digitalPinToPCICR(_receivePin))
^~~~~~~~~~~~~~~~~
digitalPinToPort
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:558:46: error: 'digitalPinToPCICRbit' was not declared in this scope
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
Archiving .pio\build\nrf52840_dk\lib52f\libBluefruit52Lib.a
Compiling .pio\build\nrf52840_dk\FrameworkArduino\Tone.cpp.o
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:558:46: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
digitalPinToPort
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:558:42: error: '_BV' was not declared in this scope
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:558:42: note: suggested alternative: '_B'
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~
_B
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:559:8: error: 'digitalPinToPCMSK' was not declared in this scope
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~
Compiling .pio\build\nrf52840_dk\FrameworkArduino\Uart.cpp.o
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:559:8: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~
digitalPinToPort
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:559:46: error: 'digitalPinToPCMSKbit' was not declared in this scope
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:559:46: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
digitalPinToPort
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:574:7: error: 'digitalPinToPCMSK' was not declared in this scope
if (digitalPinToPCMSK(_receivePin))
^~~~~~~~~~~~~~~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:574:7: note: suggested alternative: 'digitalPinToPort'
if (digitalPinToPCMSK(_receivePin))
^~~~~~~~~~~~~~~~~
digitalPinToPort
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:575:45: error: 'digitalPinToPCMSKbit' was not declared in this scope
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
Compiling .pio\build\nrf52840_dk\FrameworkArduino\WInterrupts.c.o
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:575:45: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
digitalPinToPort
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:575:41: error: '_BV' was not declared in this scope
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:575:41: note: suggested alternative: '_B'
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~
_B
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp: In member function 'virtual size_t SoftwareSerial::write(uint8_t)':
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:610:21: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:610:21: note: suggested alternative: 'AREF'
uint8_t oldSREG = SREG;
^~~~
AREF
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:611:3: error: 'cli' was not declared in this scope
cli(); // turn off interrupts for a clean txmit
^~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:615:26: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope
tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
^~~~~~~~~~~~~~~~~~~~~
Compiling .pio\build\nrf52840_dk\FrameworkArduino\WMath.cpp.o
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp: In member function 'virtual void SoftwareSerial::flush()':
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:658:21: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^~~~
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:658:21: note: suggested alternative: 'AREF'
uint8_t oldSREG = SREG;
^~~~
AREF
.pio\libdeps\nrf52840_dk\SoftwareSerial\SoftwareSerial.cpp:659:3: error: 'cli' was not declared in this scope
cli();
^~~
Compiling .pio\build\nrf52840_dk\FrameworkArduino\WString.cpp.o
*** [.pio\build\nrf52840_dk\lib963\SoftwareSerial\SoftwareSerial.cpp.o] Error 1