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,270
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
  • 8,901
23 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
  • 16.9k
22 votes
Accepted

Clearing USART (UART) interrupt flags in an STM32?

Generally, you only need to handle the interrupt flags which you have specifically enabled with USART_ITConfig(). However, if you enable the RXNE interrupt (...
bitsmack's user avatar
  • 16.9k
21 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,613
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
  • 18.7k
20 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
  • 18.7k
18 votes
Accepted

Enable interrupt but no ISR

If there is no ISR defined, the location for the jump instruction in the interrupt vector will either be null, it may be a jump to an exception routine, it may jump to the beginning of the program, or ...
tcrosley's user avatar
  • 47.9k
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
16 votes

Should all traps always be defined?

Yes, it's a good idea - the only downside is a bit of extra code size, and you have to decide what to do with the trap (emit a message on the serial port? turn on a "FAILED" light? Silently reboot? ...
pjc50's user avatar
  • 46.7k
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
13 votes
Accepted

Should all traps always be defined?

My informal rule is: If an interrupt is enabled, then you should have code that handles it. If you don't write code for an interrupt, disable it. If you can't disable it, write code for it. Even ...
Adam Davis's user avatar
  • 20.4k
13 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.5k
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
12 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
  • 599
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,662
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
  • 24.4k
10 votes
Accepted

AVR SEI instruction

Empirical results! While the other answers are thoughtful and well reasoned, they are all incomplete or just conjecture. Where the documentation is ambiguous, we must experiment and we must test every ...
bigjosh's user avatar
  • 9,958
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
  • 46.4k
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.1k
9 votes
Accepted

STM32F7 gets stuck in external interrupt callback function

Update: I found the mistake. The SysTick interrupt priority was set to the lowest (15), so calling HAL_Delay() from an ISR with the same or higher priority caused an infinite loop in the HAL_Delay ...
deinoppa's user avatar
  • 179
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
8 votes
Accepted

Reset Interrupt - Beginning or End of ISR?

Your question isn't limited to FIFOs or any particular interrupt-causing hardware. Clear interrupt conditions as soon as you know you will handle that condition. In the case of vectored interrupts,...
Olin Lathrop's user avatar
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
  • 77.5k

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