Go Down

Topic: Adjusting UART packet length on Nano 33 BLE Sense (Read 199 times) previous topic - next topic

prototyper481

Nov 20, 2020, 06:14 pm Last Edit: Nov 20, 2020, 06:17 pm by prototyper481
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:

Code: [Select]
#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);
}

Klaus_K

I previously solved a communication issue using a Nano 33 IoT.
The Arduino Nano 33 BLE and IoT have very little in common.

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.

mySerial.flush();
This is an empty function and does nothing on the Arduino Nano 33 BLE.


prototyper481

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:

Code: [Select]
#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: 

Code: [Select]
  test.begin(9600,SERIAL_7N1);

to:
Code: [Select]
  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!

Klaus_K

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.

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.

... 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?

prototyper481

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!

Go Up