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

BLE runs only while debugging on custom board (probably RTT issue)

I have problems with my custom board.

I developed the firmware with the nrf52840-PDK and there the firmware runs standalone (with RTT connected and without) or when debugged via eclipse.

Both boards (nrf52840-PDK and my custom board) have the nrf52840 QIAAAA and I'm working with Softdevice 140 and SDK 14.2.

If I run the firmware from my own custom board, everything seems to work when debugging via eclipse or when RTT is not connected. The advertising starts and the device can be found from e.g. nrf-connect and connected.

Usually I use RTT for debugging (on nrf52840-PDK) and everything works fine. The custom board is programmed via jlink from an external nrf52 DK.

If I connect via RTT to my custom board, the advertising does not work correctly. Without RTT, it works.

The power profile (with PPK) looks the same if connected with RTT and without, the advertising seems to have started but nrf-Connect can't receive advertising packets.

Could it be some timing/crystal issue? What are the differences when connected via RTT and when not?

I changed NRF_SDH_CLOCK_LF_SRC from NRF_CLOCK_LF_SRC_XTAL to NRF_CLOCK_LF_SRC_SYNTH and the behaviour is the same. So the 32khz crystal should not be the problem.

It seems to have something to do with the hardware as I can't see this behaviour on the nrf52840-PDK.

21.03.18 Updated LF test, updated to clarify the problem. There was another connection problem but it seems they are different issues (see https://devzone.nordicsemi.com/f/nordic-q-a/32590/error-133-0x85-gatt-error-with-htc-u11-life)

Parents
  • Hi,

    Could you try to enable the HF crystal after startup just to see if it makes any difference? The HF crystal is always "on" in debug interface mode. Although it does not explain why it works when RTT is disabled.

    int main()

    {

        NRF_CLOCK->TASKS_START  = 1;

        while ( NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

        //app initalization

     Do you have any IOs,etc on the custom board that could be used to indicate if the program goes in a reset loop? 

     

     

  • I had to use the following code snippet

    In some test apps I had issues to start and with this code, it seems to start. Does this mean there is an issue with the HF crystal?

    Unfortunately it does not help with the rtt problem, as you already mentioned.

    I can connect only when RTT is not used,

  • Sorry, meant to say NRF_CLOCK->TASKS_HFCLKSTART. 

    "I can connect only when RTT is not used"

    Just so I understand this correctly, when not used, does that mean that you have disabled RTT logging in the code, or that you are not connecting the debugger and viewing the logs? 

    I have not managed to reproduce this issue here. Please try with the hex file below on your board to see if you get the same result (RTT is enabled in code):

    hrs_w_s140.hex 

     

Reply
  • Sorry, meant to say NRF_CLOCK->TASKS_HFCLKSTART. 

    "I can connect only when RTT is not used"

    Just so I understand this correctly, when not used, does that mean that you have disabled RTT logging in the code, or that you are not connecting the debugger and viewing the logs? 

    I have not managed to reproduce this issue here. Please try with the hex file below on your board to see if you get the same result (RTT is enabled in code):

    hrs_w_s140.hex 

     

Children
  • Logging and RTT is always enabled in code. I just connect the debugger and view the logs and then its not working any longer.

    I will try with your hexfile. Are there all BSP pins disabled? I have different peripherals connected (some on default bsp pins) and don't want to interfere with them.

  • I disabled IOs, reset pin, and set the LF source to the internal RC to make sure that it would run on your board. 

  • Can you please also set

        NRF_CLOCK->TASKS_HFCLKSTART  = 1;
        while ( NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

    otherwise the firmware does not start at all without RTT connected.

    With RTT I can see the output:

    682420203: <info> app: Heart Rate Sensor example started.
    682420203: <info> app: Fast advertising.

    but can't connect with nfconnect. The device does not appear when scanning.

    If I flash the same hexfile on my DK I can connect to it.

  • Why did you want me to test to start the HFCLK manually?

    As I said, in another firmware, If I remove those lines, it wont start at all. Does this mean there is and issue with the crystal?

    We are using a 12pF load crystal with 22pF Capacitors (calculation would give 21pF but there are only 22pF and 20pF capacitors available.

    Would it help to switch to a 8pF load crystal (with 12pF capacitors)? Can this be the problem, that the crystal does not start fast enough?

  • "Why did you want me to test to start the HFCLK manually?"

    To get an indication whether this issue was clock related. This replicates the clock behavior when the chip is in debug interface mode.  

    I think wrong load capacitance can explain the behavior you have been seeing. Please refer to Sigurd's answer in this thread: https://devzone.nordicsemi.com/f/nordic-q-a/30204/hfxo-crystal/119935#119935