This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART CLI Framing Error During Automated Tests

Hello,

I had encountered framing errors when running automated tests that utilize UART CLI in my main code base. Currently what the test does is it sends a CLI command through the serial port and waits for the device to run the command and respond to the command. After the test gets the response, it sends another command. The issue that I am seeing is after a while of having commands constantly go through the device, it eventually reaches a point where it gets a framing error. 

I had tested to see if the example code for the nRF52480 also encounters this issue and I had found that it does.

Here are the steps I took to produce the issue:

1. I flashed the cli example in the SDK under examples/peripheral/cli 

2. I had the automated test (made with a python script) send the command "print all hello my name is nrf52"

3. I then had the test read the serial and check if the output was "hello my name is nrf52". If the output is not this, then the test had failed for that cycle

4. I had the test run for about 250 cycles and at least 1 of those cycles would have a framing error (usually a lot more than just 1 fail though)

I was wondering if there was any known method that would prevent this framing issue from occurring? The only effective one that I have found so far is by putting a 100ms delay before the device responds to the test. I am hoping there might be a solution that does not rely on a delay though.

  • Hi,

    When sending long sequences of data back-to-back on UART, the risk is that any inaccuracy of the baudrate between the peers will cause framing errors. The reason being that the receiver typically not be able to synchronize as well on the start bit. Adding a delay after n bytes can help, and likely the delay can be about 1byte long to avoid the issue.  Starting the HFCLK on the peer may reduce the risk, since it is more stable. Also, using a different USB->UART bridge can help, e.g. from FTDI instead of the built-in SEGGER.

    Kenneth

Related