Skip to main content
Copy edited
Source Link
bitsmack
  • 17k
  • 9
  • 55
  • 116

How to check if specific pheriperalperipheral interrupt is enabled in NVIC?

I'm using an STM32F4 Discovery board with STST's standard peripheral library (SPL). I have a situation with a circular buffer: timer interrupt is polling buttons and filling a circular buffer every millisecond if a button is pressed, with an index of that button. MainThe main loop then takes it out of the circular buffer and executes the appropriate command. Both thoseof these actions require multiple steps (checking and changing indices to circular buffer, ...).

When this is happening in the main loop, the timer interrupt has to be disabled for that short while (so that the indices don't get messed up), but I don't want to disable all interrupts just for that. Also, it is preferable for an interrupt to still be serviced if it happened while it was disabled.

I tried to do this by disabling the timer interrupt for that specific timer (TIM6 in my case) onin the NVIC (but left it enabled on the timer itself). But then I found out that there is no way for me to check if interrupts were disabled in the first place - before disabling them (I can't enable interrupts again if they weren't enabled before, as it can mess things up).

So my questions are:

  • How do I check if a specific peripheral interrupt is enabled atin the NVIC? (There are only EnableIRQ and DisableIRQ functions.)

I tried checking value at

NVIC->ICER[((uint32_t)(IRQn) >> 5)];

and

NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5];

but they come out 0 even if the interrupt is enabled.

  • Will the interrupt still be served (if it occurred when it was disabled on NVIC side only) when enabled again?

How to check if specific pheriperal interrupt is enabled in NVIC?

I'm using STM32F4 Discovery board with ST peripheral library (SPL). I have a situation with a circular buffer: timer interrupt is polling buttons and filling circular buffer every millisecond if button is pressed, with an index of that button. Main loop then takes it out of circular buffer and executes the appropriate command. Both those actions require multiple steps (checking and changing indices to circular buffer, ...).

When this is happening in main loop, timer interrupt has to be disabled for that short while (so that indices don't get messed up), but I don't want to disable all interrupts just for that. Also, it is preferable for interrupt to still be serviced if it happened while it was disabled.

I tried to do this by disabling timer interrupt for that specific timer (TIM6 in my case) on NVIC (but left it enabled on the timer itself). But then I found out that there is no way for me to check if interrupts were disabled in the first place - before disabling them (I can't enable interrupts again if they weren't enabled before, as it can mess things up).

So my questions are:

  • How do I check if specific peripheral interrupt is enabled at NVIC? (There are only EnableIRQ and DisableIRQ functions.)

I tried checking value at

NVIC->ICER[((uint32_t)(IRQn) >> 5)];

and

NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5];

but they come out 0 even if interrupt is enabled.

  • Will interrupt still be served (if it occurred when it was disabled on NVIC side only) when enabled again?

How to check if specific peripheral interrupt is enabled in NVIC?

I'm using an STM32F4 Discovery board with ST's standard peripheral library (SPL). I have a situation with a circular buffer: timer interrupt is polling buttons and filling a circular buffer every millisecond if a button is pressed, with an index of that button. The main loop then takes it out of the circular buffer and executes the appropriate command. Both of these actions require multiple steps (checking and changing indices to circular buffer, ...).

When this is happening in the main loop, the timer interrupt has to be disabled for that short while (so that the indices don't get messed up), but I don't want to disable all interrupts just for that. Also, it is preferable for an interrupt to still be serviced if it happened while it was disabled.

I tried to do this by disabling the timer interrupt for that specific timer (TIM6 in my case) in the NVIC (but left it enabled on the timer itself). But then I found out that there is no way for me to check if interrupts were disabled in the first place - before disabling them (I can't enable interrupts again if they weren't enabled before, as it can mess things up).

So my questions are:

  • How do I check if a specific peripheral interrupt is enabled in the NVIC? (There are only EnableIRQ and DisableIRQ functions.)

I tried checking value at

NVIC->ICER[((uint32_t)(IRQn) >> 5)];

and

NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5];

but they come out 0 even if the interrupt is enabled.

  • Will the interrupt still be served (if it occurred when it was disabled on NVIC side only) when enabled again?
Added tags
Link
bitsmack
  • 17k
  • 9
  • 55
  • 116
Split long paragraphs and small spelling fixes, to improve readability; added common abbreviation "SPL"; used HTML list for question at end, to try to highlight the various pieces of data being included - tried not to change any meaning.
Source Link
SamGibson
  • 18.3k
  • 5
  • 41
  • 63

I'm using STM32F4 Discovery board with ST peripheral library (SPL). I have a situation with a circular buffer: timer interrupt is polling buttons and filling circular buffer every msmillisecond if button is pressed, with an index of that button. Main loop then takes it out of circular buffer and executes the appropriate command. Both those actions require multiple steps (checking and changing indices to circular buffer, ...). 

When this is happening in main loop, timer interrupt has to be disabled for that short while (so that indices dontdon't get messed up), but I dontdon't want to disable all interrupts just for that. Also, it is preferable for interrupt to still be serviced if it happened while it was disabled. 

I tried to do this by disabling timer interrupt for that specific timer (TIM6 in my case) on NVIC (but left it enabled on the timer itself), but. But then I found out that there is no way for me to check if interrupts were disabled in the first place - before disabling them (I cantcan't enable interrupts again if they werentweren't enabled before, as it can mess things up). 

So my questions are:

  • How do I check if specific peripheral interrupt is enabled at NVIC? (There are only EnableIRQ and DisableIRQ functions.)

How do I check if specific peripheral interrupt is enabled at NVIC? (There are only EnableIRQ and DisableIRQ functions.) I tried checking value at

NVIC->ICER[((uint32_t)(IRQn) >> 5)];NVIC->ICER[((uint32_t)(IRQn) >> 5)];

and

NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5];NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5];

but they come out 0 even if interrupt is enabled.

Will interrupt still be served (if it occured when it was disabled on NVIC side only) when enabled again?

  • Will interrupt still be served (if it occurred when it was disabled on NVIC side only) when enabled again?

I'm using STM32F4 Discovery board with ST peripheral library. I have a situation with a circular buffer: timer interrupt is polling buttons and filling circular buffer every ms if button is pressed with an index of that button. Main loop then takes it out of circular buffer and executes the appropriate command. Both those actions require multiple steps (checking and changing indices to circular buffer, ...). When this is happening in main loop, timer interrupt has to be disabled for that short while (so that indices dont get messed up), but I dont want to disable all interrupts just for that. Also, it is preferable for interrupt to still be serviced if it happened while it was disabled. I tried to do this by disabling timer interrupt for that specific timer (TIM6 in my case) on NVIC (but left it enabled on the timer itself), but then I found out that there is no way for me to check if interrupts were disabled in the first place - before disabling them (I cant enable interrupts again if they werent enabled before as it can mess things up). So my questions are:

How do I check if specific peripheral interrupt is enabled at NVIC? (There are only EnableIRQ and DisableIRQ functions.) I tried checking value at

NVIC->ICER[((uint32_t)(IRQn) >> 5)];

and

NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5];

but they come out 0 even if interrupt is enabled.

Will interrupt still be served (if it occured when it was disabled on NVIC side only) when enabled again?

I'm using STM32F4 Discovery board with ST peripheral library (SPL). I have a situation with a circular buffer: timer interrupt is polling buttons and filling circular buffer every millisecond if button is pressed, with an index of that button. Main loop then takes it out of circular buffer and executes the appropriate command. Both those actions require multiple steps (checking and changing indices to circular buffer, ...). 

When this is happening in main loop, timer interrupt has to be disabled for that short while (so that indices don't get messed up), but I don't want to disable all interrupts just for that. Also, it is preferable for interrupt to still be serviced if it happened while it was disabled. 

I tried to do this by disabling timer interrupt for that specific timer (TIM6 in my case) on NVIC (but left it enabled on the timer itself). But then I found out that there is no way for me to check if interrupts were disabled in the first place - before disabling them (I can't enable interrupts again if they weren't enabled before, as it can mess things up). 

So my questions are:

  • How do I check if specific peripheral interrupt is enabled at NVIC? (There are only EnableIRQ and DisableIRQ functions.)

I tried checking value at

NVIC->ICER[((uint32_t)(IRQn) >> 5)];

and

NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5];

but they come out 0 even if interrupt is enabled.

  • Will interrupt still be served (if it occurred when it was disabled on NVIC side only) when enabled again?
Source Link
Loading