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

app_timer() not working on custom nRF51822 target board

I have a problem that I can't figure out. I have a custom board with an nRF51822 QFAB. The board will run a test application that uses nrf_delay_ms() to toggle an output pin, but when I attempt to replace nrf_delay() with an app_timer it hangs when initializing the SOFT_DEVICE_HANDLER() macro.

I've attached a very basic source file that illustrates the problem. This file runs fine on my PCA10028 board, but hangs on my custom target. I've also attached my Keil project settings and the schematic of my custom target board. Thanks in advance for your help!

Attached: timer_test.c Keil settings for timer_test project.png nRF51822_QFAB_target_schematic.png

Parents
  • The issue was the low frequency clock source.

    The Nordic PCA10028 board has two external oscillators. A high frequency 16MHz and a Low frequency 32.768kHz. The Soft Device requires a low frequency clock source, and all of the example code in the Nordic SDK assumes you are using an external 32.768kHz oscillator for the soft device clock. My board only has a single 16MHz oscillator (based on the reference designs from Nordic) so I needed to tell the soft device to use the internal RC oscillator. I changed this line of code:

    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL)

    To this:

    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, NULL)

    Now the app_timer() runs on my custom hardware. Take a look at this question for more details on the different clock source options: What low-frequency clock sources can I use?

Reply
  • The issue was the low frequency clock source.

    The Nordic PCA10028 board has two external oscillators. A high frequency 16MHz and a Low frequency 32.768kHz. The Soft Device requires a low frequency clock source, and all of the example code in the Nordic SDK assumes you are using an external 32.768kHz oscillator for the soft device clock. My board only has a single 16MHz oscillator (based on the reference designs from Nordic) so I needed to tell the soft device to use the internal RC oscillator. I changed this line of code:

    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL)

    To this:

    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, NULL)

    Now the app_timer() runs on my custom hardware. Take a look at this question for more details on the different clock source options: What low-frequency clock sources can I use?

Children
Related