BLE_APP_UART Problem

I am designing a wearable device that uses BLE and UART. During the development stage, I worked with the nRF52 Development Kit and started with the ble_app_uart example from nRF5_SDK 17.1.0_ddde560. Everything worked properly at that stage.

Next, I designed my own PCB. As a reference, I used a Chinese module (XL52832.D01). This module also worked correctly. However, when I assembled the components on my custom PCB, some issues appeared.

Most of the BLE peripheral examples, such as ble_app_blinky and other peripheral demos, run without problems on my PCB. But ble_app_uart does not work. I tried changing many parameters and tested both the 32 MHz and 32.768 kHz oscillators. I could not find any hardware fault, yet ble_app_uart still fails to run.

I then checked the ERRATA documentation for possible causes. Eventually, I noticed something related to IC revisions. To investigate further, I ordered different revisions (E0, E1, and G0). None of them worked. Surprisingly, only revision B0 — the one used in the XL52832 module — works properly on my PCB.

Could you please help me understand why revision B0 works on my PCB while the others do not? And more importantly, how can I resolve this issue so that my design is compatible with all revisions?

Best regards,

  • Hi,

    SDK 17.1.0 is compatible with all nRF52832 revisions (except for the Engineering revisions). It seems unlikely that the revision is what made the difference here, so I think debugging is needed to understand the issue.

    When you write that "ble_app_uart does not work", what exactly does that mean? How does it behave? How have you debugged, and what did you learn from debugging?

  • Hello ,

     

    I appreciate your support. I can successfully flash and run several BLE examples like ble_app_blinky, ble_app_cscs, and ble_app_bps. For these, I can connect via the nRF Connect app, control LEDs (e.g., turn them ON/OFF), and observe proper behavior, including the BLE connect LED indicating a successful connection.

     

    However, when I flash the ble_app_uart example, the device does not advertise. The BLE connect LED stays off, and during scanning with nRF Connect, the "NORDIC_UART" device does not appear.

     

    Troubleshooting Steps Taken:

    Hardware Verification: I inspected the board for potential faults (e.g., soldering issues, component placement), but found no obvious problems. Since other BLE examples work fine, the hardware seems functional for basic BLE operations.

     

    Debugging with Logs: To identify the failure point, I added NRF_LOG_INFO statements throughout the initialization in main.c and used the SEGGER RTT Viewer for output. Here's the modified code snippet for reference:

     

    // Initialize.

    NRF_LOG_INFO("Program started.");

    uart_init();

    NRF_LOG_INFO("UART initialized.");

    log_init();

    NRF_LOG_INFO("Log initialized.");

    timers_init();

    NRF_LOG_INFO("Timers initialized.");

    buttons_leds_init(&erase_bonds);

    NRF_LOG_INFO("Buttons and LEDs initialized.");

    power_management_init();

    NRF_LOG_INFO("Power management initialized.");

    ble_stack_init();

    NRF_LOG_INFO("BLE stack initialized.");

    gap_params_init();

    NRF_LOG_INFO("GAP params initialized.");

    gatt_init();

    NRF_LOG_INFO("GATT initialized.");

    services_init();

    NRF_LOG_INFO("Services initialized.");

    advertising_init();

    NRF_LOG_INFO("Advertising initialized.");

    conn_params_init();

    NRF_LOG_INFO("Connection params initialized.");

     

    // Start execution.

    printf("\r\nUART started.\r\n");

    NRF_LOG_INFO("Debug logging for UART over RTT started.");

    NRF_LOG_INFO("Advertising started.");

    advertising_start();

     

    // Enter main loop.

    for (;;)

    {

        idle_state_handle();

    }

    Initial RTT Output:

    00> <info> app: Program started.

    00>

    00> <info> app: UART initialized.

    00>

    00> <info> app: Log initialized.

    00>

    00> <info> app_timer: RTC: initialized.

    00>

    00> <info> app: Timers initialized.

    00>

    • <error> app: Fatal error.

     

    This suggests the crash occurs after timers_init() but before buttons_leds_init().

    Further Testing: I commented out the buttons_leds_init() call and its log statement to isolate the issue. The updated RTT output was:

    00> <info> app: Program started.

    00>

    00> <info> app: UART initialized.

    00>

    00> <info> app: Log initialized.

    00>

    00> <info> app_timer: RTC: initialized.

    00>

    00> <info> app: Timers initialized.

    00>

    00> <info> app: Power management initialized.

    00>

    00> <error> app: Fatal error

    00>

    Now the crash appears after power_management_init() but before ble_stack_init(). This points to a potential issue in ble_stack_init() when buttons_leds_init() is skipped.

    Configuration Changes: I modified sdk_config.h to change NRF_SDH_CLOCK_LF_SRC (e.g., switching between RC, XTAL, etc.), but this did not resolve the problem—the behavior remained the same.

    It is noteworthy that when I replaced the original nRF52832-QFAA-B0 chip with a new nRF52832-QFAA-E0 on the XL52832-D01 board, the behavior of the XL52832-D01, which had previously functioned correctly, changed and began exhibiting issues similar to those observed with my custom PCB.

    It seems initialization-related, possibly tied to SoftDevice enabling, clock configuration, or resource allocation. Any suggestions for capturing the specific error code (e.g., modifying app_error_handler) or other debugging steps would be greatly appreciated!

  • Hi,

    I see. "Fatal error" is printed from the default error handler. Can you build a debug build where you have "DEBUG" defined and run again? Then the log should print the file name, line number and error code which will give us more information (see also An introduction to error handling in nRF5 projects for details on this). When you have that, can you let me know edactly which function call returns which error code?

  • Thank you, Einar Thorsrud.

    I rebuilt the project. With DEBUG enabled, I get NRF_ERROR_NO_MEM in APP_UART_COMMUNICATION_ERROR as below:
    This happens when using ble_app_uart on my custom PCB. Other examples (like ble_app_blinky) work fine.


    00> <info> app_timer: RTC: initialized.
    00>
    00> <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ..\..\..\main.c:560
    00>
    00> PC at: 0x0002C22
    00>
    00> <error> app: End of error report

  • Hi,

    There is no errror check on line 560 in ble_app_blinky main.c so it seems like you ahve modified the project. Can you share your modified project? (Prefrably the whole project, but at least let me know the code around line 560 so that we know which function returned the error code.

Related