Code example to use the RPi pico UART

Hi guys,

I share with you a modification of the blinky example for the RPi pico.

In this modification I use the RPi pico w, I modified the blinky pin of the LED and I call the debug_uart.c and debug_uart.h libraries.

The debug_uart_initialize() function will configure the UART to the standard 8 data bits, with a parity bit (null) and a stop bit (8N1) with a baudrate of 115200.

the debug_uart_send_String(ā€œā€) function is responsible for sending an unformatted string.

void main(void) {
    RESETS->RESET = RESETS->RESET & ~0x00000020lu; // take IO_BANK0 out of Reset
    PSM->FRCE_ON = PSM->FRCE_ON | 0x00000400; // make sure that SIO is powered on
    SIO->GPIO_OE_CLR = 1ul << 22;
    SIO->GPIO_OUT_CLR = 1ul << 22;
    PADS_BANK0->GPIO25 = 0x00000030;
    IO_BANK0->GPIO25_CTRL = 5;
    SIO->GPIO_OE_SET = 1ul << 22;
    init_time();

    debug_uart_initialize();
  
    for ( ; ; ) {
        // uint8_t data = 23;
        SIO->GPIO_OUT_SET = 1 << 22;
        // Delay
        delay_us((10 / 1 * 60) * 1000);
        SIO->GPIO_OUT_CLR = 1 << 22;
        // Delay
        delay_us((10 / 1 * (100 - 60)) * 1000);
        debug_uart_send_String("Send string without formatting\n");
    }
}

Iā€™m working on the option to format the string, but still without success, there is a library in the LIB folder of the example project with a printf() prototype but Iā€™m having difficulty correctly calling the functions declared there.

1 Like

Very good @Cleidir ,

If you complete this debug_print functionality, we would be happy to add it to the default library code for the RPi Pico W, if you agree to allow it.

Keep up the good work :+1:

Matic

1 Like