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

Printf() in NRF51

Hi!,

UART works fine with nrf-ble-tutorial-characteristic-CompletedCode in my nRF51-DK but I'm trying to implement in my application but not works.

These are my includes:

#include <app_error.h>
#include <app_timer.h>
#include <app_uart.h>
#include <app_util.h>
#include <app_util_platform.h>
#include <ble.h>
#include <ble_advdata.h>
#include <ble_advertising.h>
#include <ble_conn_params.h>
#include <ble_gap.h>
#include <ble_gatt.h>
#include <ble_hci.h>
#include <ble_stack_handler_types.h>
#include <ble_types.h>
#include <boards.h>
#include <bsp.h>
#include <bsp_btn_ble.h>
#include <device_manager.h>
#include <nrf_error.h>
#include <nrf_sdm.h>
#include <nrf_soc.h>
#include <nrf52_bitfields.h>
#include <pca10040.h>
#include <pstorage.h>
#include <pstorage_platform.h>
#include <sdk_errors.h>
#include <softdevice_handler.h>
#include <stdbool.h>
#include <string.h>
#include <sys/_stdint.h>
#include "custom_service.h"


static void uart_events_handler(app_uart_evt_t * p_event)
{
    switch (p_event->evt_type)
    {
        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_code);
            break;

        default:
            break;
    }
}


/**
 * @brief Inicialización UART.
 *
 */
static void uart_config(void)
{
    uint32_t                     err_code;
    const app_uart_comm_params_t comm_params =
    {
        RX_PIN_NUMBER,
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        APP_UART_FLOW_CONTROL_DISABLED,
        false,
        UART_BAUDRATE_BAUDRATE_Baud38400
    };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_events_handler,
                       APP_IRQ_PRIORITY_LOW,
                       err_code);

    APP_ERROR_CHECK(err_code);
}

And my main thread:

int main(void)
{   
    uint32_t err_code;
    bool erase_bonds;

    uart_config();
    printf("\033[2J\033[;HTest UART on NRF51\r\n");

    // Inicializa.
    timers_init();
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    device_manager_init(erase_bonds);
    gap_params_init();
    servicios_init();
    advertising_init();
    conn_params_init();

    // Inicia ejecución.
    application_timers_start();
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

    // Entra en el loop principal.
    for (;;)
    {
        power_manage();
    }
}

Baud rate of minicom is 38400.

Can you say me where is the error? Thanks.

Regards

Parents
  • Of course,

    Makefile in my_app_sdk11:

    #source common to all targets
    $(abspath ../../../../../../components/libraries/uart/app_uart_fifo.c) \
    
    #includes common to all targets
    INC_PATHS += -I$(abspath ../../../../../../components/libraries/uart)
    

    javi@PC:~/Development/Nordic/NRF-SDK/nRF5_SDK_11.0.0_89a8197/components/libraries/uart$ tree .
        .
        ├── app_uart.c
        ├── app_uart_fifo.c
        ├── app_uart.h
        └── retarget.c
        
        0 directories, 4 files
    

    Compiling file: app_uart_fifo.c
    /home/javi/Development/Nordic/NRF-SDK/nRF5_SDK_11.0.0_89a8197/components/libraries/uart/app_uart_fifo.c:14:22: fatal error: app_fifo.h: No such file or directory
    Makefile:222: fallo en las instrucciones para el objetivo '_build/app_uart_fifo.o'
     #include "app_fifo.h"
                          ^
    compilation terminated.
    make: *** [_build/app_uart_fifo.o] Error 1
    

    However, yesterday, I started to migrate from SDK11 to SDK12 and I used ble_app_uart as template.

    I put it in another post.

  • You also need to include the path to app_fifo.h in your include paths:

    INC_PATHS += -I$(abspath ../../../../../../components/libraries/fifo)
    

    And add app_fifo.c to your source files:

    C_SOURCE_FILES += $(abspath ../../../../../../components/libraries/fifo/app_fifo.c)
    
Reply Children
No Data
Related