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

APP irq priority

Hi, I have developed a BLE/ZigBee application starting from nRF5 SDK for Thread and Zigbee v3.2.0.
Now I need to add a "timer" for measurement timing most precise as possible.
I tried:
- RTC, but unfortunatly: RTC0 is locked by SoftDevice, RTC2 is locked by 802.15.4 radio functions and RTC1 is used by APP timers.
- configuring by application_timers_start() function an application timer.
In this last case, I tried to change the IRQ priority reconfiguring APP_TIMER_CONFIG_IRQ_PRIORITY macro inside sdk_config.h header file
As on comment here below, I tried with priority level 2 or 3, but as sonn as the BLE connect, the FW goes into Hard Fault Handler
Where I wrong?
In addition, using the application timer with IRQ priority level 6, irq timing is not granted: for example, using 1 millisecond timer, very often the timer is served after 3-5 milliseconds, but the very troublesome think is that the followings IRQ after this issue, starts very time shifted and the long time sincronicity is not longer granted
How can I solve this issue?
Abele

  • Hi Abele

    Using the uint32_t app_timer_cnt_get(void) you can get the current RTC1 counter value. 

    If you run it once every time your callback function runs and store the value in a variable, you can run it again later and calculate the difference in order to figure out how many ticks passed since the last callback:

    // In your callback:
    uint32_t last_callback_ticks = app_timer_cnt_get();

    // At some point later
    uint32_t current_ticks = app_timer_cnt_get();
    uint32_t ticks_since_last_callback = current_ticks - last_callback_ticks;
    uint32_t milliseconds_since_last_callback = ticks_since_last_ballback * 1000 / 32768;

    Best regards
    Torbjørn

Related