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 ...
27
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 ...
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 ...
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 ...
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 ...
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 ...
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
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
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.)...
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 ...
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:
...
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 ...
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 ...
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 ...
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 ...
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
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
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 ...
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 ...
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 ...
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 ...
8
votes
Accepted
How to distinguish between GPIO interrupts from the same interrupt handler?
Read the EXTI->PR1 register to decide
...
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 ...
8
votes
Accepted
ATtiny13A - Can't generate software PWM with CTC mode
A minimal software PWM could look like this:
...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
interrupts × 888microcontroller × 208
stm32 × 201
pic × 128
avr × 125
c × 107
timer × 101
arduino × 84
uart × 84
atmega × 55
arm × 55
embedded × 42
gpio-external-interrupt × 38
i2c × 30
microchip × 27
msp430 × 25
adc × 24
spi × 23
sleep × 21
pwm × 20
gpio × 20
programming × 16
attiny × 16
serial × 15
assembly × 15