Can not find NRF_LOG_BACKEND_UART_ENABLED in sdk_config.h

I am unable to find NRF_LOG_BACKEND_UART_ENABLED  in the sdk_config.h. I need to enable UART logging. I am having issues similar to the one posted in the link below. Wanted to see if I can debug it when I get the logs in UART. Currently I have RTT enabled but when I connect RTT the issue does not appear. It only appear when RTT is not connected. 

devzone.nordicsemi.com/.../nrf52-hangs-up-when-connected-to-app-with-attached-debugger-it-works-perfect

Parents
  • Hi,

    Are you using an example in our SDK, or is your project based on one of our examples? If so, which example?

    The different sdk_config.h does not contain every possible configuration, but you can add missing configurations to your project. You can look at other sdk_config.h to find what you can and need to add. For UART logging you need to add the following in sdk_config:

    // <e> NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend
    //==========================================================
    #ifndef NRF_LOG_BACKEND_UART_ENABLED
    #define NRF_LOG_BACKEND_UART_ENABLED 1
    #endif
    // <o> NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin 
    #ifndef NRF_LOG_BACKEND_UART_TX_PIN
    #define NRF_LOG_BACKEND_UART_TX_PIN 6
    #endif
    
    // <o> NRF_LOG_BACKEND_UART_BAUDRATE  - Default Baudrate
     
    // <323584=> 1200 baud 
    // <643072=> 2400 baud 
    // <1290240=> 4800 baud 
    // <2576384=> 9600 baud 
    // <3862528=> 14400 baud 
    // <5152768=> 19200 baud 
    // <7716864=> 28800 baud 
    // <10289152=> 38400 baud 
    // <15400960=> 57600 baud 
    // <20615168=> 76800 baud 
    // <30801920=> 115200 baud 
    // <61865984=> 230400 baud 
    // <67108864=> 250000 baud 
    // <121634816=> 460800 baud 
    // <251658240=> 921600 baud 
    // <268435456=> 1000000 baud 
    
    #ifndef NRF_LOG_BACKEND_UART_BAUDRATE
    #define NRF_LOG_BACKEND_UART_BAUDRATE 30801920
    #endif
    
    // <o> NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. 
    // <i> Size of the buffer is a trade-off between RAM usage and processing.
    // <i> if buffer is smaller then strings will often be fragmented.
    // <i> It is recommended to use size which will fit typical log and only the
    // <i> longer one will be fragmented.
    
    #ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE
    #define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64
    #endif
    
    // </e>

    Make sure that you select the correct TX pin for your device. If you are using one of the DKs this should be 6, while on the nRF52840 Dongle it should be 31.

    You also need to include the following files in main.c:

    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"

    And you need to initialize logging, for example with a log_init() function you call at the beginning of main():

    static void log_init(void)
    {
        ret_code_t err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    }

    Best regards,

    Marte

  • I am using the example in the sdk. BLE_NUS example. 

Reply Children
Related