Even Parity Settings for Serial 2 (UART2)

Asked 2 months ago, Updated 2 months ago, 1 views

If you know how to set the even parity of UART in Spresense, please let me know.
Currently, there is an error and it seems that only non-parity can be set.

Serial2.begin(9600, SERIAL_8E1);

Run this and you'll see

on the serial monitor.
UART only supports SERIAL_8N1

HardwareSerial.cpp appears to be outputting this error.
Is it not possible to use even parity in the Presense?


2022-09-30 11:40

3 Answers

The Bluetooth module was supposed to be even parity, so I hit the same wall.

As for the method I took, I was able to communicate with the Bluetooth module without any problems by changing the SDK to Even Parity and rebuilding it!

It's a prerequisite that you have an SDK buildable environment, but I'll show you how to do it.

Refer to the "Spresense SDK Getting Started Guide" to build the SDK environment.

Get both arduino and sdk sources

$git clone https://github.com/sonydevworld/spresense-arduino-compatible.git
$ git clone -- recursive https://github.com/sonydevworld/spresense.git

Launch Kernel Configuration in the sdk directory

$ ./tools/config.py-k release-m

Set UART2 parity settings to Even Parity

Device Drivers > Serial Driver Support > UART2 Configuration

Change Parity setting to 0->2

Kernel Configuration

Save and exit Kernel Configuration

Overwrite with 'y' because the following command asks if you want to overwrite it

$./tools/mkdefconfig.py-k release
release is already exists, overwrite ?(y/n)?y

Go to the arduino side and run the script

$ ./tools/prepare_arduino.sh-S../spresense-p

If the script finishes successfully, I think the following files have been updated.
spresense-arduino-compatible/Arduino 15/packages/SPRESENSE/tools/spresense-sdk/1.0.0/

  • spresense/release/include/nuttx/config.h
  • spresense/release/prebuild/libs/libnuttx.a

If you replace them with those from your Arduino environment, the sketch will remain the default SERIAL_8N1 and will work with the Even Parity setting.

2022-09-30 11:40

I am in charge of SPRESENSE support for Sony.

We extended the functionality of the Serial Library in Spresense Arduino v2.0.

You can configure Even Parity with Serial.begin (9600, SERIAL_8E1).

For detailed programming specifications, see Serial Library.

Thank you for your continued support on SPRESENSE.
SPRESENSE Support Team

2022-09-30 11:40

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.