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

NRF52840 USB_CDC_ACM + UART

Hi,

I'm trying to combine serial UART functionality into the USBD_BLE_UART example. The goal is to send data in/out to the hardware UART as well.

I started off by loading the USBD_BLE_UART example, then added the UART functions from the UART peripheral example. Build was successful, but when executing, I get a NRF_INVALID_STATE error. I can only get the firmware to run without errors by commenting out the uart_init() function, but then the UART will not function if I do so.

It seems that the error is caused in APP_UART_FIFO, under nrfx_drv_init.

I'm using SES 3.34b, with SDKv15. 

Any help appreciated. 

Parents
  • Hi,

    Is it maybe nrf_drv_uart_init() that returns NRF_INVALID_STATE ? That indicates that the uart driver is already initialized.

    Then this is maybe happening because nrf_log is using uart as backend, and then you try to initialize uart again after log_init()? If so, I would then recommend that you use RTT as logging backend instead.

    In sdk_config.h, set NRF_LOG_BACKEND_UART_ENABLED to 0 and NRF_LOG_BACKEND_RTT_ENABLED to 1

  • Hi Sigurd,

    Sorry for not describing the issue in enough detail. 

    You are absolutely right, the function that returns NRF_INVALID_STATE is actually nrfx_uart_init(), which resides in nrf_drv_uart_init(). It returns this error if the drv is already in initialized state.

    I have set NRF_LOG_BACKEND_UART_ENABLED to 0. Now I am getting a different error below. I couldn't manage to trace down which function triggered this error at the moment.

    <info> app: USBD BLE UART example started.
    <error> app: Communication error occurred while handling UART.
    <error> app: ERROR 12 [NRF_ERROR_DATA_SIZE] at :0
    PC at: 0x00000000
    <error> app: End of error report

    This error occurred right on start up, and I'm not transmitting anything on the UART lines.

Reply
  • Hi Sigurd,

    Sorry for not describing the issue in enough detail. 

    You are absolutely right, the function that returns NRF_INVALID_STATE is actually nrfx_uart_init(), which resides in nrf_drv_uart_init(). It returns this error if the drv is already in initialized state.

    I have set NRF_LOG_BACKEND_UART_ENABLED to 0. Now I am getting a different error below. I couldn't manage to trace down which function triggered this error at the moment.

    <info> app: USBD BLE UART example started.
    <error> app: Communication error occurred while handling UART.
    <error> app: ERROR 12 [NRF_ERROR_DATA_SIZE] at :0
    PC at: 0x00000000
    <error> app: End of error report

    This error occurred right on start up, and I'm not transmitting anything on the UART lines.

Children
Related