Adjusting UART packet length on Nano 33 BLE Sense

Hello!

I previously solved a communication issue using a Nano 33 IoT. The key to that solution was to adjust the number of bits in the UART packets to have 7 data bits, no parity, and a single stop bit. When switching to the Nano 33 BLE Sense I found that using the standard “mySerial.begin(speed, config)” is only applying the speed, but the configuration never changes.

After some testing, it seems to be sending 1 start bit and 8 bits of data with no parity and 1 stop bit, regardless of what I enter for the config. I verified this using an oscilloscope and varying the config from Serial_5N1 to Serial_8N1 and varying the number of bits between 1 and 2 to check if a parity bit was ever generated.

Does anyone know how to adjust the UART packet length on a Nano 33 BLE Sense?

Here is the code I’ve been using to test the configuration settings:

#include <Arduino.h>


UART mySerial (digitalPinToPinName(6), digitalPinToPinName(5), NC, NC);


void setup() {
  mySerial.begin(1000000, SERIAL_7N1);
}


uint8_t x[5] = {0b00000000, 0b00010000, 0b00011000, 0b11111111, 0b01010101};


void loop() {
  mySerial.write(x, 1);
  mySerial.flush();
  delay(5);
}

prototyper481:
I previously solved a communication issue using a Nano 33 IoT.

The Arduino Nano 33 BLE and IoT have very little in common.

prototyper481:
Does anyone know how to adjust the UART packet length on a Nano 33 BLE Sense?

The library suggest you can use 7 or 8 data bits. I could not find a corresponding bit in the datasheet of the nRF52840.
The datasheet and the library suggest you can include a parity bit and have one or two stop bits.

prototyper481:
mySerial.flush();

This is an empty function and does nothing on the Arduino Nano 33 BLE.

Ok, so I uninstalled all my old mbed stuff and reinstalled the arduino IDE. Then made sure everything was up to date after a fresh install. I found that the board version for mbed boards was updated to 1.3.0. Now when I run the following code, the arduino no longer works (and is not recognized by windows) and I have to perform a double-tap reset to load anything on the board:

#include<arduino.h>

UART test(digitalPinToPinName(6),digitalPinToPinName(5),NC, NC);
char x[2] = {0b01010101, 0b10101010};

void setup() {
  test.begin(9600,SERIAL_7N1);
}

void loop() {
  test.write(0b10101010);
  delay(5);
}

It will work when I change the line:

  test.begin(9600,SERIAL_7N1);

to:

  test.begin(9600);

However, this has the wrong number of data bit (8 instead of 7). Any advice is appreciated, this snag is costing a ton of time and resources!

prototyper481:
Now when I run the following code, the arduino no longer works (and is not recognized by windows) and I have to perform a double-tap reset to load anything on the board:

Your code crashes mbedOS (see orange LED blink pattern). Likely because the setting is not supported.

prototyper481:
However, this has the wrong number of data bit (8 instead of 7).

As said before, I could not find any bit in the datasheet for this setting. I doubt the UART supports 7 data bits.

prototyper481:
... this snag is costing a ton of time and resources!

Is this a commercial project? Maybe you need some professional support. You know I do this for fun?

Klaus_K:
Your code crashes mbedOS (see orange LED blink pattern). Likely because the setting is not supported.
As said before, I could not find any bit in the datasheet for this setting. I doubt the UART supports 7 data bits.
Is this a commercial project? Maybe you need some professional support. You know I do this for fun?

Gotcha! My bad. I didn't consider the register level because I assumed the API would be able to handle this.

I checked the register map and found the config register you specified. Some further research on the Nordic site has confirmed beyond any doubt that 7-data-bit UART is a dead end for this board. It supports 8 data bits only,

Sad day, as rtos and the built-in peripherals would have simplified my hardware design. Back to the drawing board.

I also do this for fun. Thanks for your help!