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

Debug UART with SDK 7.1

I just switched over from SDK v6 to SDK v7.1 (installed via those Keil Packs). The UART has suddenly stopped working (via Segger USB COM port) and I can no longer see any debug console output. It's just giving me garbage characters.

I'm using the NRF51822 on the PCA10001 reference design.

Is this a known issue? If I wanted to 'start over' in providing a console output, how would I go about enabling UART debug console output over the Segger COM port? I've already searched the forum and have been unable to resolve this.

I also tried following the SDK instructions for Debug, but that didn't work either. developer.nordicsemi.com/.../a00074.html

38400 bps, 8N1, no parity, no flow control. Changed the bps to 115200, same settings, no change. No matter what settings I change I still get garbage characters.

Thanks.

Parents
  • Found a solution for the UART problem.

    Stop using app_trace_init and app_trace_log (deselect app_trace in pack routine selection) import from ble_app_hrs_printf the routine retarget.c

    #include <stdio.h>
    #include <stdint.h>
    #include "simple_uart.h"
    #include "nordic_common.h"
    #include "nrf51.h"
    #include "nrf51_bitfields.h"
    #include "boards.h"**
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    void retarget_init(void)
    {
        simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);
    }
    
    int fputc(int ch, FILE * p_file) 
    {
        simple_uart_put((uint8_t)ch);
        return 0;
    }
    
    /**
     *@}
    
     **/
    

    Then use retarget_init(); to initialize the UART and printf to output message. With this setup the baudrate is 38400 no parity no flow control.

    This works with PCA10001 (COM3) and PCA10028 (COM6).

    Claude

Reply
  • Found a solution for the UART problem.

    Stop using app_trace_init and app_trace_log (deselect app_trace in pack routine selection) import from ble_app_hrs_printf the routine retarget.c

    #include <stdio.h>
    #include <stdint.h>
    #include "simple_uart.h"
    #include "nordic_common.h"
    #include "nrf51.h"
    #include "nrf51_bitfields.h"
    #include "boards.h"**
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    void retarget_init(void)
    {
        simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);
    }
    
    int fputc(int ch, FILE * p_file) 
    {
        simple_uart_put((uint8_t)ch);
        return 0;
    }
    
    /**
     *@}
    
     **/
    

    Then use retarget_init(); to initialize the UART and printf to output message. With this setup the baudrate is 38400 no parity no flow control.

    This works with PCA10001 (COM3) and PCA10028 (COM6).

    Claude

Children
  • I'm currently having the same problem, but Keil packs is requiring that I include app_trace_init and log because I'm using the BLE device manager library, which requires them. Any solutions/way around this to get retarget and printf working again?

  • Thanks for the tip! I was just running into this when upgrading from SDK 6.

    The big question is "why"? What has broken?

    Here's the default HRS example's output with device_manager output turned on:

    [DM]: >> dm_init. [DM]: Initializing Application Instance 0x00000000. [DM]: Initializing Connection Instance 0x00000000. [DM]: Initializing Peer Instance 0x00000000. [DM]: Initializing Peer Instance 0x00000001. [DM]: Initializing Peer Instance 0x00000002. [DM]: Initializing Peer Insta0[DM]ae[DM]aa[DM]nt[DM]:n[DM]:[e[DM][e[DM]: DevFF[DM]:c4[DM]]F[DM]: Dedx[DM]:[e[DM]:e[DM]: Dev00[DM]: F[DM]x0[DM]: DeeF[DM]:[a[DM]:e[DM]: Dev [DM]:BF[DM]xF[DM]: DeA0[DM]:[l[DM]:c[DM]: Dev0 [:[D_[DMa[D<[ADV]: Starting fast advertisement[DM]: Request to allocation connection instance [DM]:[00]: Connection Instance Allocated. [DM]: Searching for device 0x8F 0xEC 0x53 0x9B 0x38 0x6C. [DM]:[DI 0x00]: Device type 0xFF. [DM]: Device Addr 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. [DM]:[DI 0x01]: Device type 0xFF. [DM]: Device Addr 0xFF 0xFF 0xFF 0xFF 0F[DM]e[DM]: Decx [DMDe[DM]: Dedx[DM]:c[DM][DM:y[DM]: DeA [DM] t

Related