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

app_ble_uart uart must be hooked up?

I'm facing the issue, that the app_ble_uart example just works if I hook up TX/RX of my USB - UART converter. Is this a desired behaviour? It doesn't seem to start and advertise if I don't hook up TX/RX.

Parents
  • You may get a UART framings error if the RX pin becomes floating once you disconnect the USB-UART converter. To avoid this I would suggest to enable internal pull up on the RX pin after uart init.

    /**@snippet [Handling the data received over UART] */
    
    
    /**@brief  Function for initializing the UART module.
     */
    /**@snippet [UART Initialization] */
    static void uart_init(void)
    {
        uint32_t                     err_code;
        app_uart_comm_params_t const comm_params =
        {
            .rx_pin_no    = RX_PIN_NUMBER,
            .tx_pin_no    = 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);
    
    
        NRF_P0->PIN_CNF[RX_PIN_NUMBER] |= GPIO_PIN_CNF_PULL_Msk;
    }
    /**@snippet [UART Initialization] */

Reply
  • You may get a UART framings error if the RX pin becomes floating once you disconnect the USB-UART converter. To avoid this I would suggest to enable internal pull up on the RX pin after uart init.

    /**@snippet [Handling the data received over UART] */
    
    
    /**@brief  Function for initializing the UART module.
     */
    /**@snippet [UART Initialization] */
    static void uart_init(void)
    {
        uint32_t                     err_code;
        app_uart_comm_params_t const comm_params =
        {
            .rx_pin_no    = RX_PIN_NUMBER,
            .tx_pin_no    = 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);
    
    
        NRF_P0->PIN_CNF[RX_PIN_NUMBER] |= GPIO_PIN_CNF_PULL_Msk;
    }
    /**@snippet [UART Initialization] */

Children
Related