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

How to print UART message in "ble_app_uart" project in SDK15.2

Hi,

Does "ble_app_uart" project can print debug message from "UART" interface? How can I do this job?

PS. My UART Port is at P0.18 (TX) and P0.19(RX).

Thank you,

Chianglin

Parents
  • Hi,

    The ble_app_uart project prints debug messages over Segger RTT by default.  But you can use printf() if you wish to write data to the UART.

    Vidar

  • Hi Vidar,

    I had try to use printf() to write data to UART, and the UART interface is connect to PC, but I can not find any data  in PC console.

    My environment is:

    1. Use Nordic's nRF52832 EVM board.

    2. Use "ble_app_uart" project of SDK15.2, and I doesn't modify any thing.  Actually, there have "printf()" function in main.c.

    But I still can not found any message from PC via UART interface.

    How can I fix this problem?

    Thank you,

    Chianglin

  • Hi Chianglin,

    Is this the Nordic devkit (nRF52 DK - PCA10040)? In that case, you shouldn't need to modify anything, UART data will be written to the JLINK CDC UART port (virtual com port) on your PC. You just need a serial client and select the correct COM port and baudrate (default 115200)

    Best regards,

    Vidar

  • Hi Vidar,

    I am using the EVM board like following image.

    Yes, it can print debug message via "JLink CDC UART Port" to PC.

    If I want to print debug message to other UART pin (for example: P0.06 for TXD and P0.08 for RXD), how to modify the source code to do this job?

    Thank you,

    Chianglin

  • Hi Chianglin,

    You can change the pin numbers in uart_init(), but the UART pins will not be routed to the JLink chip then. 

    Best regards,

    Vidar

  • Hi Vidar,

    Can I modify TXD to P0.18 and RXD to P0.19 for UART output?

    Can I modify following code to do this purpose?

    static void uart_init(void)
    {
        uint32_t                     err_code;
        app_uart_comm_params_t const comm_params =
        {
            .rx_pin_no    = 19	/*RX_PIN_NUMBER*/,
            .tx_pin_no    = 18	/*TX_PIN_NUMBER*/,
            .rts_pin_no   = RTS_PIN_NUMBER,
            .cts_pin_no   = CTS_PIN_NUMBER,
            .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
            .use_parity   = false,
    #if defined (UART_PRESENT)
            .baud_rate    = NRF_UART_BAUDRATE_115200
    #else
            .baud_rate    = NRF_UARTE_BAUDRATE_115200
    #endif
        };
    
        APP_UART_FIFO_INIT(&comm_params,
                           UART_RX_BUF_SIZE,
                           UART_TX_BUF_SIZE,
                           uart_event_handle,
                           APP_IRQ_PRIORITY_LOWEST,
                           err_code);
        APP_ERROR_CHECK(err_code);
    }
    

    In original source code, the TXD, RXD is define at P0.06, P0.08.  The UART can print message and I can find BLE device on "RF UART APP".

    But when I modify to P0.18 and P0.19, the "nRF UART APP” can not find this BLE device.

    Do I also need to do something?

    Thank you,

    Chianglin

Reply
  • Hi Vidar,

    Can I modify TXD to P0.18 and RXD to P0.19 for UART output?

    Can I modify following code to do this purpose?

    static void uart_init(void)
    {
        uint32_t                     err_code;
        app_uart_comm_params_t const comm_params =
        {
            .rx_pin_no    = 19	/*RX_PIN_NUMBER*/,
            .tx_pin_no    = 18	/*TX_PIN_NUMBER*/,
            .rts_pin_no   = RTS_PIN_NUMBER,
            .cts_pin_no   = CTS_PIN_NUMBER,
            .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
            .use_parity   = false,
    #if defined (UART_PRESENT)
            .baud_rate    = NRF_UART_BAUDRATE_115200
    #else
            .baud_rate    = NRF_UARTE_BAUDRATE_115200
    #endif
        };
    
        APP_UART_FIFO_INIT(&comm_params,
                           UART_RX_BUF_SIZE,
                           UART_TX_BUF_SIZE,
                           uart_event_handle,
                           APP_IRQ_PRIORITY_LOWEST,
                           err_code);
        APP_ERROR_CHECK(err_code);
    }
    

    In original source code, the TXD, RXD is define at P0.06, P0.08.  The UART can print message and I can find BLE device on "RF UART APP".

    But when I modify to P0.18 and P0.19, the "nRF UART APP” can not find this BLE device.

    Do I also need to do something?

    Thank you,

    Chianglin

Children
Related