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 ...
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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? ...
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.)...
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 ...
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:
...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
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-...
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. ...
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 ...
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 ...
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 ...
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,...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
interrupts × 876microcontroller × 207
stm32 × 198
pic × 127
avr × 125
c × 105
timer × 101
arduino × 81
uart × 81
arm × 55
atmega × 54
embedded × 39
gpio-external-interrupt × 38
i2c × 31
microchip × 27
msp430 × 25
adc × 24
spi × 22
sleep × 21
pwm × 20
gpio × 19
programming × 16
attiny × 16
serial × 15
assembly × 15