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

52810 SDK 16 can we enable UART logging just by changing SDK_config.h, as the RTT logging?

SDK 16.0

52810

S112

From the sample code of SDK we can see that the UART is enabled by code ourself, as the following. However, what's the usage of the NRFX_UARTE_ENABLED and NRFX_UARTE_CONFIG_LOG_ENABLED for? Can we enable UART logging just by changing those items in SDK_config.h? In other words, can we choose either RTT or UART just by changing SDK_config.h, instead of changing code to either call RTT or UART?

Basically I want to use RTT logging while initial coding, and UART logging while the performance tuning, to avoid the DK impact. I don't want to change code. I just want to change SDK_config.h. How can I achieve that?

Thanks,

  const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          UART_HWFC,
          false,
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_115200
#else
          NRF_UARTE_BAUDRATE_115200
#endif
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

    APP_ERROR_CHECK(err_code);

  • Yes, that should be possible, to enable/disable UART logging you set NRF_LOG_BACKEND_UART_ENABLED to 1/0 and for RTT logging you use NRF_LOG_BACKEND_RTT_ENABLED. This assumes that everything else in the application is set up to support UART/RTT (which it is by default for most of the applications in the nRF5 SDK 16.0).

    In SDK 16 you also have to set NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED to 0 in order to see RTT logging.

    Also, you should not use the NRFX config options in sdk_config.h, look for the corresponding non-NRFX definition instead. Since the legacy definitions (non NRFX) will override the NRFX definitions. E.g. UART_ENABLED will override NRFX_UART_ENABLED.

    Best regards,

    Simon

Related