Skip to main content
33 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,283
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,046
25 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
  • 2,848
24 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
  • 17k
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
  • 21.1k
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
  • 21.1k
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
15 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
14 votes

Interrupt latency on a STM32F303 MCU

Problem Well you have to look at the functions you are using, you can't just make assumptions on the speed of code you haven't looked at: This is the EXTI_GetITStatus function: ...
Arsenal's user avatar
  • 17.8k
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
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,707
11 votes

Logging multiple sensors data to SD card at same time: writing hangs up

Never, never, never put file I/O in an interrupt routine - unless it is the only routine to do file I/O. And then still don't do it! An interrupt can interrupt anything: including file I/O. And ...
John Burger's user avatar
  • 1,493
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
  • 26.6k
10 votes
Accepted

What is the point of having a level-based interrupts?

Level-based interrupts can safely be shared and cascaded easily and reliably; by contrast, reliably sharing edge-triggered interrupts is often difficult and sometimes impossible. When using level-...
supercat's user avatar
  • 47k
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.5k
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
  • 158k
8 votes

How to use UART rx data from ISR to main loop?

The conventional way to do this is to use a circular buffer (sometimes also referred to as a circular queue). The Rx interrupt routine inserts received data bytes into the queue using its input ...
Michael Karas's user avatar
8 votes
Accepted

Multithreading on AVR

To create an adequate multi-threading system, you need to do a 'context switch' see Wikipedia 'context switch' for an explanation. The code needs to make the 'context switch' be 'invisible' to each ...
gbulmer's user avatar
  • 10.1k
8 votes
Accepted

Differences between Interrupts and sampling for hardware button?

Debouncing is a FAQ. You should be able to find... nearly unlimited numbers of web pages on the topic. Smith commented about Jack Ganssle's widely read PDF on the topic, as well. And with all these ...
jonk's user avatar
  • 78.3k
8 votes
Accepted

Understanding difference between Interrupt Address and interrupt vector address

The Interrupt Service Routine (ISR) is the program that's to be executed when an interrupt occurs. Some CPU architectures have fixed addresses which the CPU will execute a subroutine call to. This is ...
TonyM's user avatar
  • 23.4k
8 votes
Accepted

How to distinguish between GPIO interrupts from the same interrupt handler?

Read the EXTI->PR1 register to decide ...
followed Monica to Codidact's user avatar
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.5k
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,863
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 Pefhany's user avatar

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