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

SDK15.3.0 App Timer What is the execution time of app_timer_stop, and app_timer_start

Hello,

SDK 15.3.0

nRF52840-DK

s140

IDE:SES

I am running into an issue using the app timer and LPComp together. The error is NRF_FAULT_ID_SDK_ERROR, With RTT output ERROR 4 [NRF_ERROR_NO_MEM] @ line 10 in the code below

static void lpcomp_event_handler(nrf_lpcomp_event_t event)
{
    ret_code_t err_code;
    if (event == NRF_LPCOMP_EVENT_UP)
    {
        bsp_board_led_invert(BSP_BOARD_LED_0); // just change state of first LED
        voltage_rising_detected++;
        voltage_rising_total++;
        err_code = app_timer_stop(m_timer_id);
        APP_ERROR_CHECK(err_code);
        err_code = app_timer_start(m_timer_id, APP_TIMER_TICKS(50), NULL);
        APP_ERROR_CHECK(err_code);
    }
}

The App timer does not have a reset function, so I need to stop and start the timer every time I would like to restart it. I have a signal I need to count that will run every 104ms, with 50ms of rising edges to count at 88Khz and a down time of 54ms. I intend to use the LPComp to count the rising edges of the 88kHz signal then on the last count of the signal the timer will start (and not be restarted by a new rising edge) and when the timer handler is called I will reset the count and calculate the value from that count. I essentially need to be able to detect when there are no more rising edges to know when to reset the count for the next cycle. 

What might be causing the NRF_FAULT_ID_SDK_ERROR and ERROR 4 [NRF_ERROR_NO_MEM]?

What is the execution time of app_timer_stop, and app_timer_start? (I assume the execution is on the long side to be run in an interrupt, but an alternative method is not clear to me)

Parents
  • Hi Paul,

    Regarding the problem with the NRF_ERROR_NO_MEM, you can get rid of it by increasing the queue size of the timer as mentioned here.

    If you want the execution of list handling to be done immediately, then you can probably increase the priority of APP_TIMER_CONFIG_IRQ_PRIORITY a bit so that the SWI1 IRQ is triggered immediately when set to pend. M

  • // <o> APP_TIMER_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 APP_TIMER_CONFIG_IRQ_PRIORITY
    #define APP_TIMER_CONFIG_IRQ_PRIORITY 6
    #endif

    The APP_TIMER_CONFIG_IRQ_PRIORITY is set to 6. The documentation says 0,1,4,5 are reserved for the SoftDevice. I suspect that if I move this to a reserved priority, or a higher priority the SoftDevice will not be happy. So I am under the impression that 6 is the highest priority I can safely use for the app timer in combination with the SoftDevice.

Reply
  • // <o> APP_TIMER_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 APP_TIMER_CONFIG_IRQ_PRIORITY
    #define APP_TIMER_CONFIG_IRQ_PRIORITY 6
    #endif

    The APP_TIMER_CONFIG_IRQ_PRIORITY is set to 6. The documentation says 0,1,4,5 are reserved for the SoftDevice. I suspect that if I move this to a reserved priority, or a higher priority the SoftDevice will not be happy. So I am under the impression that 6 is the highest priority I can safely use for the app timer in combination with the SoftDevice.

Children
Related