Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Atomic FIFO example and queries about interrupts

Hi, I'm trying to use Atomic FIFO in my application, where multiple interrupts of different priorities are trying to read from and write to same FIFO. I couldn't find any simple example which uses Atomic FIFO. I'm using SDK 14.2 on nrf52832. The documentation shows simple implementation of read operations but not the write operations.

Also in the documentation it says that "Atomic types are limited to nrf_atomic_u32_t and nrf_atomic_flag_t". Does it mean I can only have u32 datatypes in the fifo(or in the structs that are in fifo) ? What about other data types u64, u8, u16 etc ?

Besides this, can you please answer following questions as well ?

If i have multiple interrupts of same priorities, can a new interrupt pause the execution of the interrupt being currently executed ? If not, then does this new interrupt gets lost or will it execute after the current interrupt finishes its execution ? If yes, then what happens if there are a lots of interrupts in line/queue to be handled ? what is the maximum number of interrupts that can be handled if generated simultaneously or very closer to each other in time ? In my application I'm using GPIOTE, timers, app_timers to generate around 20+ interrupts and they might all occur simultaneously.

  • > If i have multiple interrupts of same priorities, can a new interrupt pause the execution of the interrupt being currently executed ?

    Nope. Only interrupt with a lower priority number can preempt a running interrupt. The next handler function gets called as soon as the running one finished (see tail chaining).

    You may want to read the NVIC documentation on infocenter.arm.com, because that is an ARM standard component.

    Nothing prevents you from setting many (up to all available) interrupts to "pending" in the same instruction cycle, and the result could work - as in "every handler gets called eventually".This assumes interrupt handlers behave by properly resetting the respective interrupt flags (NRF DRV handlers do this for you in almost all cases).

  • Thanks, and about the at_fifo example I was able to implement the fifo read function by simply using "item_get" and "item_free" functions.

Related