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

App Timer tutorial, nrf_drv_clock_lfclk_request

I am debugging a small program for the nRF52, which uses the App Timer and communicates over UART. I am trying to keep up with bug fixes, and so I'm using SDK 11.0.

The UART works fine, my program prints a greeting in the first few lines of main(). But I don't seem to be setting up timer interrupts correctly, since the printing that is supposed to occur at each timer tick (every 5 seconds), in my timer handler function, is not taking place.

In order to get my program to compile at all, I had to write the LFCLK request in my timer configuration function as follows:

nrf_drv_clock_lfclk_request(false);

I copied that from an example somewhere, I'm not sure exactly where.

However, the App Timer tutorial shows that nrf_drv_clock_lfclk_request takes NO arguments. The function definition that I'm seeing wants a pointer to a nrf_drv_clock_handler_item_t.

I have to wonder why this discrepancy exists. It might be because the tutorial isn't written for SDK 11.0, but I don't know for sure. I also wonder whether my code in fact fails to start the LFCLK.

I will post my complete program if it helps. I thought that I would start with the first discrepancy I found before dumping 100 lines of code to the forums. Thanks for your help.

Parents
  • Following up to myself: I just discovered the function nrf_drv_clock_lfclk_is_running(). After executing this...

    err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);
    nrf_drv_clock_lfclk_request(false);
    

    ...nrf_drv_clock_lfclk_is_running() returns FALSE. I have confirmed that I'm not starting LFCLK. From my reading, I think that nrf_drv_config.h and the Makefile may also affect the hardware. The App Timer tutorial says that App Timer uses RTC1. I have modified my nrf_drv_config.h to read:

    #define RTC1_ENABLED 1
    

    When RTC1 triggers, which software interrupt does it use? It might use SWI0, since the Makefile that comes with the App Time tutorial does not include the line:

    CFLAGS += -DSWI_DISABLE0
    

    I made sure that my Makefile also does not include this line. Any clues? Thanks again.

Reply
  • Following up to myself: I just discovered the function nrf_drv_clock_lfclk_is_running(). After executing this...

    err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);
    nrf_drv_clock_lfclk_request(false);
    

    ...nrf_drv_clock_lfclk_is_running() returns FALSE. I have confirmed that I'm not starting LFCLK. From my reading, I think that nrf_drv_config.h and the Makefile may also affect the hardware. The App Timer tutorial says that App Timer uses RTC1. I have modified my nrf_drv_config.h to read:

    #define RTC1_ENABLED 1
    

    When RTC1 triggers, which software interrupt does it use? It might use SWI0, since the Makefile that comes with the App Time tutorial does not include the line:

    CFLAGS += -DSWI_DISABLE0
    

    I made sure that my Makefile also does not include this line. Any clues? Thanks again.

Children
No Data
Related