Questions tagged [interrupt]
Interrupts allow the processor to suspend normal operation temporarily so that a high-priority software or hardware event can be handled instead.
48 questions
18
votes
1
answer
28k
views
How do interrupts work on the Arduino Uno and similar boards?
Please explain how interrupts work on the Arduino Uno and related boards using the ATmega328P processor. Boards such as the:
Uno
Mini
Nano
Pro Mini
Lilypad
In particular please discuss:
What to use ...
5
votes
2
answers
8k
views
Read RC receiver channels using Interrupt instead of PulseIn
I am designing my own quadcopter control algorithm, whereby I currently read 4 RC receiver channels using PulseIn on each loop in the following manner:
ch1_raw = pulseIn(rcPin1, HIGH, 25000);
In ...
1
vote
1
answer
1k
views
Can external interrupts be OR'd together on the '328 (Uno)?
I'm thinking about how to handle a rotary encoder. I'm planning on using interrupts and would like to use both the 'A' and 'B' phase transitions to generate interrupts. I'm wondering if there is any ...
14
votes
4
answers
56k
views
Using millis() and micros() inside an interrupt routine
The documentation for attachInterrupt() says:
... millis() relies on interrupts to count, so it will never increment inside an ISR. Since delay() requires interrupts to work, it will not work if ...
9
votes
2
answers
4k
views
How to update a variable in an ISR using Timers
I'm trying to check the frequency of Timer3 using a counter. The value of the counter, declared as volatile, is incremented in the ISR and every second the sum is shown in the main loop and the value ...
4
votes
1
answer
989
views
ATTiny13 Interrupt Issue
I have recently been working on a project that I had initially been designing with an Arduino Nano, and I was able to create functioning code for my application, but for cost / space reduction I ...
3
votes
2
answers
8k
views
IR Receiver interrupt and arduino sleep mode
I need to put my arduino into the sleep mode in order to consume less power. My arduino receives IR data and do some work with it, but I need to make it sleep until there is no data. If the data has ...
3
votes
1
answer
993
views
Cannot set MOSI pin low even after ending SPI
I'm building a battery operated device and must shutoff MOSI pin during sleep because it leaks current through the SD card if I don't (about 400 µA).
Problem is, it won't stay off. I've looked at ...
3
votes
1
answer
489
views
Waking up async the Arduino while it is sleeping periodically
I´m using LowPower.h and PinChangeInt.h libraries to put my Arduino into the sleep mode every 8 seconds and then it wakes up, modifies a counter and it goes to sleep again, but also I need to wake it ...
2
votes
2
answers
821
views
Why PJ0 and PJ1 are not reporting as PCINT pins
When the sketch shown at end-of-question is compiled and uploaded to an Arduino board, it is supposed to Serial-print a list of available digital pins, showing for each pin whether it supports PWM or ...
1
vote
1
answer
5k
views
How to assign an interrupt to a button press with an ATtiny? (interrupt not fired with my code)
(Here is finally a solution).
I'm using the following code on a ATtiny45 to assign an interrupt to a button press (pin #7, PB2, INT0). However the LED doesn't blink when the button is pressed, as if ...
0
votes
2
answers
546
views
ATtiny85 with sleep and serial
I want to communicate over serial to another device (dfplayer) and also set the microcontroller into sleep mode.
The ATtiny85 does not have a hardware serial pin so I need to use a virtual serial (...
22
votes
3
answers
6k
views
Can a function be called automatically when an input changes?
Currently, my sketch is checking an input pin every time round the main loop. If it detects a change, it calls a custom function to respond to it. Here's the code (trimmed down to the essentials):
...
21
votes
2
answers
54k
views
How many interrupt pins can an Uno handle?
I am looking at using a 7 channel RC receiver with the Arduino Uno R3. In the documentation, there are mentions of a maximum of 2 interrupt pins, whereas on certain other blogs I have seen mentions of ...
9
votes
2
answers
21k
views
Why the need to use the volatile keyword on global variables when handling interrupts in Arduino?
I am familiar with the keyword Volatile being used to declare variables that are shared among multiple threads on a software application (basically on a multithreaded application).
But why do I need ...