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

How to handle app_uart_communication_error

I am using the nrf52832 to communicate uart with hw flow control and a baudrate of 9600 and fifo.

Everything is going well most of the time, but sometimes the other device needs to be reset, and the reset causes it to set its tx pin low while it is resetting. The nrf sees this as a frame error and thus it gets a APP_UART_COMMUNICATION_ERROR. The default handling of this in the example programs is to reset the nrf, but this is not acceptable in my case, so I am trying to handle the frame errors. But how should I do this in the best way? I am fine by losing the data when frame errors occurs.

I have tried to just ignore the frame error and this seems to work, but then I will no longer get the APP_UART_DATA_READY event. I have also tried to call app_uart_get and app_uart_flush when the error occurs, but this doesn't solve the problem.

What am I doing wrong?

Edit: The fix that Ole posted didn't work for me, so I tried to do the minimum code that would give me the error. main.c

I am communicating with a gsm module and sending at commands to it. So I expect the data to look like this, and it does look like this until i get a frame error. image description

This is a zoomed out image of that command being send every second. After a few seconds the gsm module is reset (when the GSM out goes low). This gives a frame error, and there will no longer be any "data ready events".image description

The following picture is after the gsm module has raised its tx pin again. Since the fifo isn't being emptied the cts pin goes high and will never be lowered again. The gsm module will keep sending data in this example though, as i haven't included the command for enabling hw flow control on the gsm command in this code.

Parents Reply Children
Related