While working with a RPi Pico UART RX routine in C using pico-sdk, I have realized that uart_get_hw(uart0)->rsr; reports an error - that is, it has a value different from 0 (in my case 13, which is 0b1101, which as per https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf ("UART: UARTRSR Register"), indicates FE Framing error, along with BE Break error, and OE Overrun error.

As far as I can see from my printfs, this error persists whenever the RX interrupt routine gets called. And the datasheet also states:

BE Break error. This bit is set to 1 if a break condition was detected, indicating that the received data input was held LOW for longer than a full-word transmission time (defined as start, data, parity, and stop bits). This bit is cleared to 0 after a write to UARTECR.

So, apparently I have to clear these error bits manually. OK, but how do I clear this bit, or write to UARTECR?

The only reference I found is:


Both UARTRSR and UARTECR registers are located at same address 0x4000C004. When a data is read from that location the content of UARTRSR is read and when write occurs on that location UARTECR is written.

As mentioned in the TRM any write to UARTECR should clear the error status.

So UART_clearRxError( UART0_BASE ); should work in your case. Please check if the error is constantly being set for the peripheral, this may be because of you setup. Please recheck the pin connections.

... however, pico-sdk does not have a UART_clearRxError function.

I have tried:

uart_get_hw(UART_ID)->rsr = 0;

... but this seems to just freeze the program/stop the execution.

So, how can I write to the UARTRSR register via pico-sdk, so as to clear the error bits?

1 Answer 1


Well, as per the discussion in Write to UARTECR with pico-sdk? (How to clear UART RX error for pico (RP2040)?) - Raspberry Pi Forums, the answer is likely:

hw_clear_bits(&uart_get_hw(uart0)->rsr, UART_UARTRSR_BITS);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.