This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

Debugging nRF51822 application through UART using SDK8.1 and eclipse/gcc toolchain

I would like a working example of a simple application that uses soft_device (either S110 or S120) plus UART debugging. I have read many posts in this forum about this topic but it is difficult (so far impossible for me) to get a complete/end-to.end answer.

Constraints:

  • nRF51 SDK 8.1
  • Using eclipse/gcc toolchain as expalined in Tutorial devzone.nordicsemi.com/.../
  • Using a standalone module (no development kit) so UART pins need to be configurable (I am using Red Bear Lab BLE Nano module but other modules are also possible)

Thanks for your help!

Parents
  • Thanks for the hints. They have helped me on my goal (debugging/loggig using the eclipse/gcc toolchain explained in the tutorial

    @nguyen: I had already tried app_uart without success. I retried it again and I got it working:) Silly mistake from my side but I was using the default UART initialisation which I had to update

    const app_uart_comm_params_t comm_params =
    {
        RX_PIN_NUMBER,
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        APP_UART_FLOW_CONTROL_ENABLED,
        false,
        UART_BAUDRATE_BAUDRATE_Baud38400
    };
    

    I disabled HW flow control (change APP_UART_FLOW_CONTROL_ENABLED by APP_UART_FLOW_CONTROL_DISABLED) and my serial connection started working at 38400 bauds. I used the Serial Monitor of my Arduino IDE but any other serial terminal app should work.

    Interesting to note that the UART PINs (RX_PIN_NUMBER, TX_PIN_NUMBER) are assigned/defined in bsp.h -> boards.h -> pca10028.h (I am using BLE Nano but I use flag CFLAGS = -DBOARD_PCA10028 in makefile)

    @stian Thanks a lot for pointing out the RTT tutorial. I had dismissed it because it included keil in the requirement list (I am using eclipse). However, I read it and it was straight forward to enable RTT logging with J-link in eclipse.

    I extracted the RTT zip folder in my SDK component folder and then added a couple of files/lines to my makefile:

    C_SOURCE_FILES += \
    ...........
    ../../../../../../components/rtt/RTT/SEGGER_RTT.c \
    ../../../../../../components/rtt/RTT/SEGGER_RTT_printf.c \
    ...........
    
    
    INC_PATHS += -I../../../../../../components/rtt/RTT
    

    Finally I included the RTT library in the main.c file of the project:

    #include "SEGGER_RTT.h" 
    

    No need to initialise RTT with a explicit call. You can start using it in the code straight away:

    SEGGER_RTT_WriteString(0, "Hello World!\n"); 
    

    or

    SEGGER_RTT_printf(0, "Length %d \n", p_evt_write->len);  
    

    If you have J-Link (and J-Link RTT Viewer application as explained in the tutorial) there is no need for UART debugging anymore!

Reply
  • Thanks for the hints. They have helped me on my goal (debugging/loggig using the eclipse/gcc toolchain explained in the tutorial

    @nguyen: I had already tried app_uart without success. I retried it again and I got it working:) Silly mistake from my side but I was using the default UART initialisation which I had to update

    const app_uart_comm_params_t comm_params =
    {
        RX_PIN_NUMBER,
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        APP_UART_FLOW_CONTROL_ENABLED,
        false,
        UART_BAUDRATE_BAUDRATE_Baud38400
    };
    

    I disabled HW flow control (change APP_UART_FLOW_CONTROL_ENABLED by APP_UART_FLOW_CONTROL_DISABLED) and my serial connection started working at 38400 bauds. I used the Serial Monitor of my Arduino IDE but any other serial terminal app should work.

    Interesting to note that the UART PINs (RX_PIN_NUMBER, TX_PIN_NUMBER) are assigned/defined in bsp.h -> boards.h -> pca10028.h (I am using BLE Nano but I use flag CFLAGS = -DBOARD_PCA10028 in makefile)

    @stian Thanks a lot for pointing out the RTT tutorial. I had dismissed it because it included keil in the requirement list (I am using eclipse). However, I read it and it was straight forward to enable RTT logging with J-link in eclipse.

    I extracted the RTT zip folder in my SDK component folder and then added a couple of files/lines to my makefile:

    C_SOURCE_FILES += \
    ...........
    ../../../../../../components/rtt/RTT/SEGGER_RTT.c \
    ../../../../../../components/rtt/RTT/SEGGER_RTT_printf.c \
    ...........
    
    
    INC_PATHS += -I../../../../../../components/rtt/RTT
    

    Finally I included the RTT library in the main.c file of the project:

    #include "SEGGER_RTT.h" 
    

    No need to initialise RTT with a explicit call. You can start using it in the code straight away:

    SEGGER_RTT_WriteString(0, "Hello World!\n"); 
    

    or

    SEGGER_RTT_printf(0, "Length %d \n", p_evt_write->len);  
    

    If you have J-Link (and J-Link RTT Viewer application as explained in the tutorial) there is no need for UART debugging anymore!

Children
Related