Datasheet

Table Of Contents
4.3.6.5. UARTEINTR
The error interrupt is asserted when an error occurs in the reception of data by the UART. The interrupt can be caused by
a number of different error conditions:
framing
parity
break
overrun.
You can determine the cause of the interrupt by reading the Raw Interrupt Status Register, UARTRIS, or the Masked
Interrupt Status Register, UARTMIS. It can be cleared by writing to the relevant bits of the Interrupt Clear Register,
UARTICR (bits 7 to 10 are the error clear bits).
4.3.6.6. UARTINTR
The interrupts are also combined into a single output, that is an OR function of the individual masked sources. You can
connect this output to a system interrupt controller to provide another level of masking on a individual peripheral basis.
The combined UART interrupt is asserted if any of the individual interrupts are asserted and enabled.
4.3.7. Programmer’s Model
The Pico SDK provides a uart_init function to configure the UART with a particular baud rate. Once the UART is initialised,
the user must configure a GPIO pin as UART_TX and UART_RX. This can be seen in the following example:
Pico SDK: https://github.com/raspberrypi/pico-sdk/tree/pre_release/src/rp2_common/pico_stdlib/stdlib.c Lines 13 - 19
13 void setup_default_uart() {
14 uart_init(uart_default, PICO_DEFAULT_UART_BAUD_RATE);
15 gpio_set_function(PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART);
16 gpio_set_function(PICO_DEFAULT_UART_RX_PIN, GPIO_FUNC_UART);
17 bi_decl_if_func_used(bi_2pins_with_func(PICO_DEFAULT_UART_RX_PIN,
Ê PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART));
18 bi_decl_if_func_used(bi_program_feature("stdout to UART"));
19 }
To initialise the UART, the uart_init function takes the following steps:
Deassert the reset
Enable clk_peri
Set enable bits in the control register
Enable the FIFOs
Set the baud rate divisors
Set the format
Pico SDK: https://github.com/raspberrypi/pico-sdk/tree/pre_release/src/rp2_common/hardware_uart/uart.c Lines 42 - 68
42 void uart_init(uart_inst_t *uart, uint baudrate) {
43 invalid_params_if(UART, uart != uart0 && uart != uart1);
44
45 // TODO: Make this return an int?
46 if (clock_get_hz(clk_peri) == 0)
47 return;
RP2040 Datasheet
4.3. UART 449