Nano 33 BLE and Serial1 8E2 format causing Mbed OS to crash

In our drone design we are using SBUS to communicate between the radio control receiver (FrSKY X8R) and a Nano 33 BLE. SBUS is serial comms which runs at a non standard baud rate (100000) and is inverted to make life more difficult.
However that isn't the problem. We are connecting via Serial1 on the Nano and can set the baud rate ok (at least it isn't crashing, although looking at this post, it probably isn't setting the correct baud rate). The problem is when you use the optional config parameter in Serial1.begin().

The default config is 8 data bits, no parity, and one stop bit (8N1). SBUS uses 8 data bits, even parity and two stop bits (i.e. SERIAL_8E2).

If you set Serial1 to the default config (Serial1.begin(100000, SERIAL_8N1)) there is no problem, but if you try to set it to 8E2 then Mbed OS crashes (orange LED SOS).

You only need one line in setup() to reproduce the problem:

Serial1.begin(100000, SERIAL_8E2);

Looking at the Serial class in the ArduinoCore, I can see that using this optional config parameter calls format() in the serial base class, but I can't see how this config data is passed in or handled. This is likely due to my unfamiliarity with c++.

Can anyone cast any light on this problem or how to fix it?

Currently, only SERIAL_8N1 is supported for Serial1 on the Nano 33 BLE:

Efforts are underway to fix this issue.

I added a note about this to the documentation:

but the publishing system must be broken because I see it never made it into the Arduino Language Reference here on arduino.cc. I'm investigating that publishing issue now.

Thanks pert for the response.

Similar to the setting of non standard baud rates, are there any problems with controlling this via registers?

For example:

UART0 Base address 0x40002000
UART CONFIG register address offset 0x56C
Therefore register address we want to modify is 0x4000256C

From page 479 of the Product Secification, we want to set:

STOP = 1 // Two stop bits; and
PARITY = 0x7 // Include even parity bit

So we want CONFIG = 0x0000000F, and the code would look something like:

uint32_t config = 0x0000000F;
uint32_t *pRegister = ( uint32_t * )0x4000256C;
*pRegister = config;

An update on this:

pert:
but the publishing system must be broken because I see it never made it into the Arduino Language Reference here on arduino.cc. I'm investigating that publishing issue now.

I reported the issue to Arduino and it has now been published:
https://www.arduino.cc/reference/en/language/functions/communication/serial/begin/#_notes_and_warnings

I know that comes too late to be of help to you, but perhaps it will save the next person from the same confusion.

reefwing:
Similar to the setting of non standard baud rates, are there any problems with controlling this via registers?

Unfortunately, I don't know anywhere near enough about the nRF52840, Mbed OS, or the Arduino Mbed OS Boards platform to be able to answer that question. Perhaps someone here on the forum with more knowledge than me will be able to help.

You might find some useful information at the bug report about this that was submitted to the Mbed OS repository by one of the Arduino developers:

Thanks again Pert.

For anyone else looking at this, the code above seems to work. This in conjuction with the code from the non-standard baud rate post allowed me to set a baud rate of 100000 with a config of 8E2 on Serial1, and be able to read SBUS packets (after inverting it with a transistor).