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

Using same UART for both CLI and printf 

I am adding CLI service with my existing project developed based on ble_app_uart.

CLI Init function :

static void _cli_init(void)
{
ret_code_t ret;

#if CLI_OVER_UART
nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
uart_config.pseltxd = TX_PIN_NUMBER;
uart_config.pselrxd = RX_PIN_NUMBER;
uart_config.hwfc = NRF_UART_HWFC_DISABLED;

ret = nrf_cli_init(&m_cli_uart, &uart_config, true, true, NRF_LOG_SEVERITY_INFO);
APP_ERROR_CHECK(ret);
#endif
}

Uart init function used in ble_app_uart : 

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);
}

This results in resting mcu. 

How I can solve this issue.

Parents
  • Hi Martin

    Reseting mcu : nrf52 is getting reset continuously (reason - I think due two separate initialization for UART)

    I will check for error.

    The main concern is who we can use UART for both CLI and NUS with one initialization.

    One is using uart_app configuration and other simple uart initialization as code is mentioned in the question above.

    In other words, I want to make a common function for both cli_init and uart_init.

    I hope you get my point, feel free to ask if you want me to explain more.

Reply
  • Hi Martin

    Reseting mcu : nrf52 is getting reset continuously (reason - I think due two separate initialization for UART)

    I will check for error.

    The main concern is who we can use UART for both CLI and NUS with one initialization.

    One is using uart_app configuration and other simple uart initialization as code is mentioned in the question above.

    In other words, I want to make a common function for both cli_init and uart_init.

    I hope you get my point, feel free to ask if you want me to explain more.

Children
No Data
Related