Skip to main content
34 votes

Why should interrupts be short in a well configured system?

Not only is there no reason you can't do that. An event driven system is not uncommon. BUT. On many architectures if you are in one interrupt you cannot have another, so even a low-priority interrupt ...
old_timer's user avatar
  • 8,383
28 votes

What do the different interrupts in PCIe do? I referring to MSI, MSI-X and INTx

The three buzzwords that you've asked about, INTx, MSI and MSI-x, are a part of a long and winding history of interrupt/IRQ delivery on the x86 PC architecture. Other computer architectures may share ...
frr's user avatar
  • 3,079
26 votes
Accepted

Is it possible to interrupt the copy process of a struct by an interrupt in embedded C?

Yes. Pretty much everything in an MCU can be interrupted by an interrupt request. When the interrupt handler completes the previous code will just continue so it is usually not a problem. In a ...
filo's user avatar
  • 9,166
25 votes

STM32F4 How are Preemption Priorities and Sub-Priorities used?

The Preemption Priority allows an ISR to be preempted (interrupted) by another interrupt of higher priority. When the higher-priority interrupt is completed, the lower-priority interrupt continues ...
bitsmack's user avatar
  • 17.1k
21 votes
Accepted

Avoiding global variables when using interrupts in embedded systems

There is a de facto standard way to do this (assuming C programming): Interrupts/ISRs are low-level and should therefore only be implemented inside the driver related to the hardware that generates ...
Lundin's user avatar
  • 24.3k
21 votes
Accepted

What's the difference between setting SysTick Interrupt in NVIC and using it as an exception?

A couple of definitions first: In the Cortex-M programming manual, an Exception is anything that breaks the normal program flow, and invokes a handler from the vector table, and Interrupts are a ...
followed Monica to Codidact's user avatar
20 votes

Is there a microcontroller with zero interrupt jitter?

You are approaching this from the wrong direction. You shouldn't have a specification which says "I need such mcu to measure times between two events with precision up to 1 cycle". You ...
Lundin's user avatar
  • 24.3k
18 votes

Why should interrupts be short in a well configured system?

Re-entrancy is/becomes a major headache the more your ISRs are complex. The wikipedia entry has a pretty succinct description of a re-entrant ISR: A reentrant interrupt handler is an interrupt ...
MB.'s user avatar
  • 283
17 votes

Stm32 Event and interrupts

Why do we then use Events on stm32 if you can't execute some code when they happens? Interrupts will typically be used to execute a few lines of code by the ARM core (NVIC, interrupt handlers, etc.)....
Mike Borgholthaus's user avatar
15 votes

Is it a good idea to perform I2C Communication in the ISR?

In the olden days, when we had a single thread of execution, and many sources of interrupts, you kept the ISR as short and quick as possible, so that it is able to keep up with many frequent interrupt ...
Simon Fitch's user avatar
13 votes

Nested Vectored Interrupt Controller (NVIC) - Why is it "nested" and "vectored"?

In the old days, a CPU would have one, or maybe two interrupt lines. Maybe one would be Non Maskable Interrupt for critical things, the other shared for everything. In this case, either an external ...
Sean Houlihane's user avatar
13 votes

Is it possible to interrupt the copy process of a struct by an interrupt in embedded C?

Any operation that is not atomic can be interfered with by an interrupt. This kind of programming is often very different than most other programming and can be confusing to people who haven't studied ...
Sam's user avatar
  • 619
13 votes
Accepted

Efficiency of interrupts sharing the same Interrupt Service Routine

It's fine. The only thing I'd change is to get rid of the else. This potentially improves the time efficiency, by not requiring a separate invocation of the ISR for ...
Dave Tweed's user avatar
  • 184k
12 votes
Accepted

Inaccurate timer interrupt STM32

There are two things wrong with your code: 1) you attempt to reset and restart the counter in the interrupt handler with "TIM1->EGR |= 0x01;" . But you're using the automatic reload mode of the ...
james's user avatar
  • 1,807
12 votes

Is it a good idea to perform I2C Communication in the ISR?

I don't believe it's a good idea, in general. The I2C protocol allows for clock stretching, which means that any I2C device you're trying to talk to can effectively stop your bus, or at least dork ...
Scott Seidman's user avatar
11 votes

Is it possible to interrupt the copy process of a struct by an interrupt in embedded C?

The whole point of interrupts is that they can (and do) happen all the time, and are designed to have zero impact on any code that happens to be running when they occur. All the registers are saved, ...
Echelon's user avatar
  • 211
11 votes
Accepted

How to set an oscilloscope for measurement of interrupt service routine execution time

On TDS2014, the DISPLAY button menu includes persistence, which can be set to infinite. It should be able to capture the pulse-width of the GPIO signal. If the ISR duration was constant, you should ...
glen_geek's user avatar
  • 29.7k
10 votes

Avoiding global variables when using interrupts in embedded systems

this use of global variables goes against the grain to me This is the real problem. Get over it. Now before the knee-jerkers immediately rant about how this is unclean, let me qualify that a bit. ...
Olin Lathrop's user avatar
10 votes

Why should interrupts be short in a well configured system?

For a general purpose computer, keeping the interrupt handler short permits normal processing to be reasonably deterministic which may or may not be an issue depending on application. In a hard real ...
Peter Smith's user avatar
  • 22.9k
9 votes

Mutex in interrupts

There are several ways: Make each piece of state small enough to be updated atomically by the hardware. For example, if you're on a 16 bit machine (like a Microchip dsPIC, for example), then make ...
Olin Lathrop's user avatar
9 votes
Accepted

Program never goes into interrupt

If you are 100% sure about the interrupt setup being correct, this is a generic how to make C++ code callable from C question which is much better explained elsewhere, but in short, you don't have a ...
Justme's user avatar
  • 196k
8 votes

Mutex in interrupts

In my MCU programs (Atmel, PIC, ARM) I use: disable interrupts critical action enable interrupts My critical actions are of very short duration. Most of them are ...
Oldfart's user avatar
  • 14.7k
8 votes
Accepted

ATtiny13A - Can't generate software PWM with CTC mode

A minimal software PWM could look like this: ...
JimmyB's user avatar
  • 3,963
8 votes
Accepted

Reading interrupt safe ring buffer

Such macros are usually put where there is code that must not be interrupted by any interrupt; so yes, disabling all interrupts is what you'd typically do here. Note that on more complex cores, this ...
Marcus Müller's user avatar
8 votes

Is there a microcontroller with zero interrupt jitter?

I believe some of the simpler PIC series have constant interrupt latency. For example, the ancient PIC16F84 has latency listed as 3.25 Tcy (or 13 clock cycles). Unless your interrupt request is ...
Spehro 'speff' Pefhany's user avatar
8 votes
Accepted

Why is HAL_GetTick not protected by a CRITICAL SECTION?

For the STM32, read and writes of 32 bit values are inherently atomic as it is a 32 bit cpu. In contrast, the average Arduino uses an AVR cpu which is 8bit. To read/write a 32 bit value requires 4 ...
Kartman's user avatar
  • 7,105
7 votes

Interrupt Arduino if voltage is below some level or a switch which will not allow current to pass across if no sufficient voltage

Given you are trying to detect line voltage, your level of electronics knowledge, and that this will be connected to a arduino, you really need to use isolation of some sort. Here is a example: The ...
Olin Lathrop's user avatar
7 votes
Accepted

Must FreeRTOS task stack size account for interrupt stack size?

Interrupt service routine will use the stack you are also using for main(). You have a stack defined in your linker script, this is the one used for main and ISR, separate from the stack of the ...
Fabien's user avatar
  • 86
7 votes
Accepted

Does using a software delay() function have greater power consumption than using a System Timer interrupt?

Being curious myself I've made some simple measurements on a 32L152CDISCOVERY board. My test program consists of 4 tests, each displaying the elapsed seconds on the LCD. The difference between the ...
followed Monica to Codidact's user avatar
7 votes

Why should interrupts be short in a well configured system?

I've dealt with this sort of thing a lot on a previous project, and here are a few things I've dealt with (often learned the hard way). Some of the details can vary based on your chip architecture ...
bta's user avatar
  • 1,158

Only top scored, non community-wiki answers of a minimum length are eligible