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

Migrating from nrf52 DK to custom board, guidance required

Hello,

I am having some trouble migrating from the nrf52 DK to my custom board with an nRF52832 and running as standalone.
The application is working as intended when the custom board is connected to the DK debug header as well as on the DK itself.

Following the tutorial here:
devzone.nordicsemi.com/.../getting-started-with-nordics-secure-dfu-bootloader

I managed to get this to work, until it suddenly stopped. I tried going back to older code I had and I can't seem to repeat my success. (could it been a lucky upload order of the bootloader and DFU?)

Could someone please provide some pointers to the overall process, I cannot seem to find any concrete information anywhere.

My (lax) requirements:
-No need for security of any kind including CRC checks
-Programming will be done via the nrf52 DK (nrf52832) debug header
-both bootloader (required?) and application will be uploaded manually (no need to merge hex, open to try if that helps)
-Not using a softdevice
-Development on Segger

I am by no means a SW/FW developer and micros are understood in general, but am likely missing some general concepts. I would like to receive an overview of the process to see whether I am missing something. Please assume I know nothing and that I made every possible mistake.

Thank you in advance,
Nobody

Parents
  • Hi

    The first thing I'd like you to check/confirm is whether your custom board has the optional external LF crystal from our reference circuitry, as it is common when it works when the debugger is connected but not otherwise that this is missing, and that the application is not configured to use the internal LF clock instead.

    If that's the case, you can configure your application to use the internal RC oscillator instead by changing the following defines to these values in your projects sdk_config.h file.

    // <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_ACCURACY  - External clock accuracy used in the LL to compute timing.
     
    // <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
    // <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
    // <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
    // <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
    // <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
    // <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
    // <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
    // <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
    // <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
    // <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
    // <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
    // <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 
    
    #ifndef NRF_SDH_CLOCK_LF_ACCURACY
    #define NRF_SDH_CLOCK_LF_ACCURACY 1
    #endif

    Best regards,

    Simon

  • Hi Simon,

    Thanks for getting back to me on this matter.

    Yes, I have seen the missing/misconfigured LF source issue many times in my searches here and I thought I had it properly configured. However, it seems my sdk_config.h is missing these exact definitions. That said, it has other, similar ones. Please see below snippets from my config that refers to LF (before adding your settings):

    //==========================================================
    // <e> NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver
    //==========================================================
    #ifndef NRFX_CLOCK_ENABLED
    #define NRFX_CLOCK_ENABLED 1
    #endif
    // <o> NRFX_CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef NRFX_CLOCK_CONFIG_LF_SRC
    #define NRFX_CLOCK_CONFIG_LF_SRC 1
    #endif
    
    // <o> NRFX_CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY
    #define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6
    #endif

    // <e> NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer
    //==========================================================
    #ifndef NRF_CLOCK_ENABLED
    #define NRF_CLOCK_ENABLED 1
    #endif
    // <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef CLOCK_CONFIG_LF_SRC
    #define CLOCK_CONFIG_LF_SRC 1
    #endif
    
    // <o> CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef CLOCK_CONFIG_IRQ_PRIORITY
    #define CLOCK_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // </e>

    Unfortunately, adding your suggestion did not make a difference. Still working normally when connected to the debugger and no signs of life when externally powered.

    I have tried removing the RTC crystal (and caps) from my board and it appears to be used by the application as intended (in debug) as it does not work at all without it. Adding the crystal and caps returned to the previous state of working when connected to the DK debug header.

    I will note that my application is a mix of multiple examples, hence I likely have a messy sdk_config file.

    On the subject of RTC, please see below how I instantiate it, hope it helps

    Parameters:

    const  nrf_drv_rtc_t           rtc = NRF_DRV_RTC_INSTANCE(2);
    static uint32_t                rtc_ticks = RTC_US_TO_TICKS(SAADC_SAMPLE_INTERVAL_MS*1000, RTC_FREQUENCY);

    In main()

    lfclk_config();
    rtc_config();

    The definitions:

    // Configre low frequency clock
    static void lfclk_config(void)
    {
        ret_code_t err_code = nrf_drv_clock_init();
        APP_ERROR_CHECK(err_code);
        nrf_drv_clock_lfclk_request(NULL);
    }
    
    // Configure RTC
    static void rtc_config(void)
    {
    
        uint32_t err_code;
    
        //Initialize RTC instance
        nrf_drv_rtc_config_t rtc_config;
        rtc_config.prescaler = RTC_FREQ_TO_PRESCALER(RTC_FREQUENCY);
        err_code = nrf_drv_rtc_init(&rtc, &rtc_config, rtc_handler);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_drv_rtc_cc_set(&rtc, 0, rtc_ticks, true);
        APP_ERROR_CHECK(err_code);
    
        //Power on RTC instance
        nrf_drv_rtc_enable(&rtc);
    }

    This was taken from the SAADC low power example:
    https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/saadc_low_power

    Looking forward to any insights.

    Best regards,

    Nobody

Reply
  • Hi Simon,

    Thanks for getting back to me on this matter.

    Yes, I have seen the missing/misconfigured LF source issue many times in my searches here and I thought I had it properly configured. However, it seems my sdk_config.h is missing these exact definitions. That said, it has other, similar ones. Please see below snippets from my config that refers to LF (before adding your settings):

    //==========================================================
    // <e> NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver
    //==========================================================
    #ifndef NRFX_CLOCK_ENABLED
    #define NRFX_CLOCK_ENABLED 1
    #endif
    // <o> NRFX_CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef NRFX_CLOCK_CONFIG_LF_SRC
    #define NRFX_CLOCK_CONFIG_LF_SRC 1
    #endif
    
    // <o> NRFX_CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY
    #define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6
    #endif

    // <e> NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer
    //==========================================================
    #ifndef NRF_CLOCK_ENABLED
    #define NRF_CLOCK_ENABLED 1
    #endif
    // <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef CLOCK_CONFIG_LF_SRC
    #define CLOCK_CONFIG_LF_SRC 1
    #endif
    
    // <o> CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef CLOCK_CONFIG_IRQ_PRIORITY
    #define CLOCK_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // </e>

    Unfortunately, adding your suggestion did not make a difference. Still working normally when connected to the debugger and no signs of life when externally powered.

    I have tried removing the RTC crystal (and caps) from my board and it appears to be used by the application as intended (in debug) as it does not work at all without it. Adding the crystal and caps returned to the previous state of working when connected to the DK debug header.

    I will note that my application is a mix of multiple examples, hence I likely have a messy sdk_config file.

    On the subject of RTC, please see below how I instantiate it, hope it helps

    Parameters:

    const  nrf_drv_rtc_t           rtc = NRF_DRV_RTC_INSTANCE(2);
    static uint32_t                rtc_ticks = RTC_US_TO_TICKS(SAADC_SAMPLE_INTERVAL_MS*1000, RTC_FREQUENCY);

    In main()

    lfclk_config();
    rtc_config();

    The definitions:

    // Configre low frequency clock
    static void lfclk_config(void)
    {
        ret_code_t err_code = nrf_drv_clock_init();
        APP_ERROR_CHECK(err_code);
        nrf_drv_clock_lfclk_request(NULL);
    }
    
    // Configure RTC
    static void rtc_config(void)
    {
    
        uint32_t err_code;
    
        //Initialize RTC instance
        nrf_drv_rtc_config_t rtc_config;
        rtc_config.prescaler = RTC_FREQ_TO_PRESCALER(RTC_FREQUENCY);
        err_code = nrf_drv_rtc_init(&rtc, &rtc_config, rtc_handler);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_drv_rtc_cc_set(&rtc, 0, rtc_ticks, true);
        APP_ERROR_CHECK(err_code);
    
        //Power on RTC instance
        nrf_drv_rtc_enable(&rtc);
    }

    This was taken from the SAADC low power example:
    https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/saadc_low_power

    Looking forward to any insights.

    Best regards,

    Nobody

Children
No Data
Related