This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Debug Log issue in Adding UART in ble_app_template

Hi,

1-I have successfully developed an app ...\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_template.

2-I have set a UART example to send data from Arduino and successfully send data from Arduino and receiving on nRF52840. I have used this example code:  ..\SDK\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\examples\peripheral\libuarte 

When I add the following part in the main BLE stop adverting and am unable to receive data from UART. Also can't see any logs in the terminal when adding this part.

    err_code = NRF_LOG_INIT(app_timer_cnt_get);
    APP_ERROR_CHECK(err_code);


    NRF_LOG_DEFAULT_BACKENDS_INIT();


    nrf_libuarte_async_config_t nrf_libuarte_async_config = {
            .tx_pin     = TX_PIN_NUMBER,
            .rx_pin     = RX_PIN_NUMBER,
            .baudrate   = NRF_UARTE_BAUDRATE_9600,
            .parity     = NRF_UARTE_PARITY_EXCLUDED,
            .hwfc       = NRF_UARTE_HWFC_DISABLED,
            .timeout_us = 100,
            .int_prio   = APP_IRQ_PRIORITY_LOW
    };

    err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config, uart_event_handler, (void *)&libuarte);

    APP_ERROR_CHECK(err_code);

    nrf_libuarte_async_enable(&libuarte);

Here is my main file. Can you please mention where I am making mistakes while adding both projects as both are working fine separately?

587302.main.c

 

Parents Reply Children
  • Below are the changes I made to make your project run:

    diff --git a/pca10056/s140/config/sdk_config.h b/pca10056/s140/config/sdk_config.h
    index e27ddb1..765b89c 100644
    --- a/pca10056/s140/config/sdk_config.h
    +++ b/pca10056/s140/config/sdk_config.h
    @@ -5674,14 +5674,14 @@
      
     
     #ifndef TIMER0_ENABLED
    -#define TIMER0_ENABLED 1
    +#define TIMER0_ENABLED 0
     #endif
     
     // <q> TIMER1_ENABLED  - Enable TIMER1 instance
      
     
     #ifndef TIMER1_ENABLED
    -#define TIMER1_ENABLED 0
    +#define TIMER1_ENABLED 1
     #endif
     
     // <q> TIMER2_ENABLED  - Enable TIMER2 instance
    @@ -7715,7 +7715,7 @@
     // <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
    +#define NRF_LOG_BACKEND_UART_ENABLED 0
     #endif
     // <o> NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin 
     #ifndef NRF_LOG_BACKEND_UART_TX_PIN
    diff --git a/main.c b/main.c
    index d908f1c..3acc34d 100644
    --- a/main.c
    +++ b/main.c
    @@ -94,7 +94,7 @@
     #include "nrf_fstorage_sd.h"
     
     // BEGIN Block Added for DFU
    -#include "C:\Nordic\SDK\nRF5SDK17009d13099\nRF5_SDK_17.0.0_9d13099\components\libraries\bootloader\nrf_bootloader_info.h"
    +#include "nrf_bootloader_info.h"
     #include "ble_dfu.h"
     #include "nrf_dfu_ble_svci_bond_sharing.h"
     #include "nrf_svci_async_function.h"
    @@ -177,7 +177,7 @@
     //---------------------------------------------------------------------------------------------------------------------------------------------
     
     //UART
    -NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    +NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 1, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
     
     static uint8_t text[] = "UART example started5.\r\nLoopback:\r\n";
     static uint8_t text_size = sizeof(text);
    @@ -3039,31 +3039,22 @@ int main(void) {
       rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL);
       APP_ERROR_CHECK(rc);
     
    -
    -
    -
    -    err_code = NRF_LOG_INIT(app_timer_cnt_get);
    -    APP_ERROR_CHECK(err_code);
    -
    -
    -    NRF_LOG_DEFAULT_BACKENDS_INIT();
    -
    -
    -    nrf_libuarte_async_config_t nrf_libuarte_async_config = {
    +  nrf_libuarte_async_config_t nrf_libuarte_async_config = {
                 .tx_pin     = TX_PIN_NUMBER,
                 .rx_pin     = RX_PIN_NUMBER,
                 .baudrate   = NRF_UARTE_BAUDRATE_9600,
                 .parity     = NRF_UARTE_PARITY_EXCLUDED,
                 .hwfc       = NRF_UARTE_HWFC_DISABLED,
                 .timeout_us = 100,
    -            .int_prio   = APP_IRQ_PRIORITY_LOW
    -    };
    +            .int_prio   = APP_IRQ_PRIORITY_LOW_MID
    +  };
     
    -    err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config, uart_event_handler, (void *)&libuarte);
     
    -    APP_ERROR_CHECK(err_code);
    +  err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config, uart_event_handler, (void *)&libuarte);
    +
    +  APP_ERROR_CHECK(err_code);
     
    -    nrf_libuarte_async_enable(&libuarte);
    +  nrf_libuarte_async_enable(&libuarte);
     

    NRF_LOG_BACKEND_UART_ENABLED was still enabled in the project you sent..

  • Hi
    I have made the mentioned changes now getting the following errors. Can you please upload the working project here? Thanks

  • you must have forgotten to enable TIMER1_ENABLED.

  • No, you have enabled the NRFX_* symbol.

Related