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

Can't run modified nrf51-DK example on custom board

Hi. I took the ble_central/experimental/ble_app_blinky_c example and modified it for my needs. It works on the nrf51-DK. Now I want to use it on a custom board with nrf51822qfab. I modified the Makefile in the following way:

changed LINKER_SCRIPT to nrf51_xxab.ld, changed the flags to -DNRF51822.

Run make flash_softdevice, and then make flash. And it doesn't work. (The simple blinky example does work) After hours of trying to understand the problem (this is my first time with Nordic), I found this thread . Now I know that the program gets stuck on

SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

I tried to make the same change in clock settings (like in the thread) but it didn't help... Please help.

Parents
  • You are sure the 16MHz crystal is working correctly? You can test this with this code:

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

    If the code continuous after the while loop, then it is working.

    The qfab chip has 128 KB of flash and 16 KB of RAM, is the FLASH and RAM LENGTH in the linker script changed to this?:

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x5000
      RAM (rwx) :  ORIGIN = 0x20001eb0, LENGTH = 0x2150
    }
    
Reply
  • You are sure the 16MHz crystal is working correctly? You can test this with this code:

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

    If the code continuous after the while loop, then it is working.

    The qfab chip has 128 KB of flash and 16 KB of RAM, is the FLASH and RAM LENGTH in the linker script changed to this?:

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x5000
      RAM (rwx) :  ORIGIN = 0x20001eb0, LENGTH = 0x2150
    }
    
Children
  • Hi Ole. I will check this later today. How about the thread I referred to? If I understood it correctly, the guy had some issues with his crystal, so he used the chip's internal(?) oscillator to make it work temporary. That's what I was trying to do myself as a last resort, without success.

  • The clock settings passed in the SOFTDEVICE_HANDLER_INIT(..) function is for the low frequency clock (LFCLK/32Khz clock). Here you can choose between using a crystal (if one is on the custom board) and the internal RC oscillator.

    When it comes to the high frequency clock (HFCLK/16MHz), it is required to use the crystal for the radio and hence required for bluetooth. If you use the internal oscillator for the LFCLK it will use the HFCLK crystal to calibrate itself. If the crystal does not work correctly, for example the load capacitors are wrong value, then the code may stop in the SOFTDEVICE_HANDLER_INIT(..) function.

  • Ok. If I pass the same parameters to SOFTDEVICE_HANDLER_INIT as described in the thread I mentioned, should this function at least return with/without an error and continue running?

  • I'm happy to say that your suggestion regarding the linker script helped. It works now. Thank you.

  • No problem. Can you mark the answer as correct (grey checkmark under the arrows) so that others can find the correct solution?