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

My app doesn't work with internal clock, but works when I debug it.

I am using nRF52832 with SDK 14. My app has bootloader and dfu. Everything was working fine with external crystal. I changed my clock source to RC and used these recommended settings in my app code and bootloader code

for sdk_config.h

// </h> 
//==========================================================

// <h> Clock - SoftDevice clock configuration

//==========================================================
// <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
 
// <0=> NRF_CLOCK_LF_SRC_RC 
// <1=> NRF_CLOCK_LF_SRC_XTAL 
// <2=> NRF_CLOCK_LF_SRC_SYNTH 

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 0
#endif

// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 16
#endif

// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
// <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
// <i>  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
#endif

// <o> NRF_SDH_CLOCK_LF_XTAL_ACCURACY  - External crystal clock accuracy used in the LL to compute timing windows.
 
// <0=> NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM 
// <1=> NRF_CLOCK_LF_XTAL_ACCURACY_500_PPM 
// <2=> NRF_CLOCK_LF_XTAL_ACCURACY_150_PPM 
// <3=> NRF_CLOCK_LF_XTAL_ACCURACY_100_PPM 
// <4=> NRF_CLOCK_LF_XTAL_ACCURACY_75_PPM 
// <5=> NRF_CLOCK_LF_XTAL_ACCURACY_50_PPM 
// <6=> NRF_CLOCK_LF_XTAL_ACCURACY_30_PPM 
// <7=> NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM 

#ifndef NRF_SDH_CLOCK_LF_XTAL_ACCURACY
#define NRF_SDH_CLOCK_LF_XTAL_ACCURACY 0
#endif

and for pca_10040.h

#define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_RC,            \
                                 .rc_ctiv       = 16,                                \
                                 .rc_temp_ctiv  = 2,                                \
                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
                                 

When it is in bootloader it does advertising and I can upload my app. But my app doesnt work. When I try to debug my app, it works well and does eveything I want but when I finish the debug it stops advertising and I cant see anything. 

Parents Reply
  • Hi kb2423, 

    there are no restrictions with using the internal RC in bootloader or the ble_app_buttonless_dfu application. 

    Are you using a custom nRF52 board or are you using a nRF52 DK? 

    So if you upload the default ble_app_buttonless_dfu application and the SoftDevice (not the bootloader) the everything works as it should regardless if you use the external crystal or the internal RC?

    The issue occurs when you set the LF clock source to the internal RC in the bootloader and upload SD+APP+BL?

    Best regards

    Bjørn

Children
  • Thanks for the reply. I am using custom board not the DK. I just tried with DK and it is working well so I understood it is the hardware problem. I was using SD+APP+BL with the external crystal and everything was fine. Then I removed external crystal from custom board and changed LF clock source to internal RC as you recommended here. Then I upload again updated  SD+APP+BL and it didn't work. I debug it to see the problem but it worked fine during the debug. I saw it did advertising. But it doesn't work without debugging. Also I tried blinky application with the same custom board and internal RC, it worked too. What can cause this problem? Thanks again. 

  • You have modified the LF Clock source configuration to use the internal RC in both the application and bootloader right? Does the bootloader advertise when you flash the BL+ SD to custom board and you have the bootloader configured to use the internal RC? If that is the case, could you flash the application and the bootloader settings page and then start a application debug session and see if you hang at sd_softdevice_enable() in nrf_sdh_enable_request() called from ble_stack_init().

     

  • Yes, I did same configurations for both the application and bootloader. Bootloader advertises when I flash the BL+ SD to custom board. When I connect custom board to the debugger or oscilloscope, it is working so I understood it uses debuggers internal resistor. Then I mount a resistor between VDD and RESET(P0.21) pin and now it is working. We had the same issue with UART on this custom board, UART doesn't work without same resistor too. Do we need that resistor between VDD and RESET? Also I accepted your answer there are no restrictions with using the internal RC in bootloader or the ble_app_buttonless_dfu application. 

Related