All Questions
Tagged with interrupts avr
125 questions
17
votes
6
answers
21k
views
Avoiding global variables when using interrupts in embedded systems
Is there a good way of implementing communication between an ISR and the rest of the program for an embedded system which avoids global variables?
It seems that the general pattern is to have a ...
15
votes
4
answers
5k
views
AVR SEI instruction
The AVR SEI instruction (http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_SEI.html)
waits for the next instruction to finish before enabling interrupts.
If I use another instruction to set ...
10
votes
2
answers
8k
views
Any reason not to use Timer0 on AVR?
Just a basic question... For arduino/avr/ATMega328 I find lots of examples using Timer1 (there's even a whole library for it) but rarely any that utilize Timer0 (or Timer2).
Now, I know that using ...
10
votes
2
answers
28k
views
Determining which pin triggered a PCINTn interrupt?
Am I correct in thinking that if you have two pins causing the same AVR PCINT interrupt, (e.g. PCINT0 vector caused by either PCINT0 or PCINT1 pins -- I think the naming overlap of vectors and pins is ...
10
votes
2
answers
8k
views
AVR interrupt service routine not executing as fast as expected (instruction overhead?)
I'm developing a small logic analyzer with 7 inputs. My target device is an ATmega168 with a 20MHz clock rate. To detect logic changes I use pin change interrupts. ...
8
votes
3
answers
2k
views
ATtiny13A - Can't generate software PWM with CTC mode
I'm trying to make a remote control RGB LED light using an ATtiny13A.
I know the ATtiny85 is better suited for this purpose, and I know I might not eventually be able to fit the whole code, but for ...
7
votes
1
answer
2k
views
Tell if interrupts are enabled
Is there a way of telling if sei()/interrupts() or cli()/...
6
votes
3
answers
10k
views
How to read whole data sent to USART with interrupt?
I am currently able to read byte by byte from USART with this code
...
6
votes
4
answers
5k
views
Multithreading on AVR
If I have an AVR micro controller and have an ISR coming up about every 100 micro seconds or so, can I change the stack pointer in the ISR and then fake multi threading?
Psuedo code:
...
6
votes
2
answers
2k
views
Teensy USB Interrupts
I'm trying to learn about interrupts using one of the Teensy USB boards. It's got an AVR AT90USB1286 chip on it. I'm using the code below, and I'm expecting my ISR block to get called and periodically ...
6
votes
2
answers
10k
views
Calculate exact timer frequency for ATTiny
Trying to wrap my head around these overflow timers for the ATTinyx5 (45 in this particular case). I seemed to have a great handle on it with the ATMega328 but I cannot get it to work the way I want ...
6
votes
1
answer
777
views
Time Base ISR Concurrency
This is sort of a "classic" problem, and I think I have a solution, but I want to vet it with this community. I am building a project using the ATtiny88 microcontroller, and I'm programming in avr-gcc....
6
votes
1
answer
7k
views
Handling timer overflow and compare interrupts in ATMega328 (Arduino)
I'm trying to simulate PMW mode on multiple pins in software by controlling a Timer2.
I'm using maximum prescaler value to get approximately 60 pulses per second when timer counts to its maximum ...
6
votes
1
answer
267
views
Millis versus centis on AVR platform
I am building a device on the AVR platform. The device will need some timing information, so I was thinking of reimplementing Arduino millis-like functionality (...
5
votes
4
answers
21k
views
Understanding interrupts and software button debounce
I'm quite new to AVR programming (avr-gcc).
To react on button-press, I am using a PCINT ISR with the internal pull-up resistor enabled like this:
...
5
votes
2
answers
3k
views
How can I control things without using delay?
I have always hated that you couldn't do other things while you used the delay(); function. However, I want to blink a LED or do whatever while using serial, but ...
5
votes
1
answer
3k
views
Overflow interrupt firing only once
I've run into an issue where, it appears, my interrupt only fires once, then simply refuses to fire again on my ATMega32U2. I have the following (stripped down) code:
...
5
votes
1
answer
823
views
ATtiny45 pin change interrupt PB5?
On the ATTiny45 data sheets it states that PB5 can be used as a digital IO pin and I want to use it to trigger a pin change interrupt, my only issue is that it is also the reset pin and the moment I ...
5
votes
2
answers
840
views
AVR: How optimize cycle-counted ISR to portable code, using inline asm
I'm trying to optimize my RX and TX interrupts to meet maximum execution time of 25 cycles while interrupts are disabled.
So far, I have found that code is optimized enough, but pushing and popping ...
4
votes
3
answers
7k
views
AVR ADC performance: interrupts vs. manual conversion
I have a device on ATMega16 microcontroller that is supposed to constantly send ADC measurement results over USART. The controller is operating at 16MHz with an external crystal and ADC prescaler is ...
4
votes
2
answers
2k
views
Interrupt fails to change variable, how so?
Problem was virtually undebuggable, the interrupt that was changing a variable would randomly fail to do so, with no apparent pattern; within interrupt code variable would change but outside of it the ...
4
votes
2
answers
863
views
How can I wake up an ATtiny84 microcontroller at specific time of the day?
I am trying to create an alarm that wakes up at a certain time and does a series of instructions. To set the times that it wakes up, I am going to use the headphone of an Android device to send ...
4
votes
2
answers
951
views
Race condition in AVR timers
I'm trying to implement a global timer, so that I can call time_us() anywhere in program and the function will return microseconds since program start. I've done this using TIMER2 (8-bit clock) and ...
4
votes
2
answers
193
views
Low power strategy for dealing with spontainious bit flips durring sleep on AVR 8-bit?
I am designing a ATTINY-based circuit that is intended to run unattended for very long periods of time on a very small battery. The device spends almost all of its time in deep sleep, and only wakes ...
4
votes
2
answers
3k
views
Can't set to Fast PWM OCRA mode
Trying to have Fast PWM mode when TOP == ORCA.
Works fine with OCA toggle (measuring correct frequency), but doesn't work in ...
4
votes
2
answers
1k
views
Moving the code and interrupt locations in Arduino
I need to be able to choose between two Arduino apps running on an atmega 1280 (megaavr) at boot time. Therefore I need to move one of those apps to a different location in program memory, and I need ...
4
votes
1
answer
5k
views
AVR: Timer overflow flag in TIFR [duplicate]
I have a little question about the TOVn flag located in the TIFRn register.
The datasheet says, if the ...
4
votes
1
answer
3k
views
Modifying Interrupt Vector Table of Atmega32
A project that I'm working on involves a cycle accurate interrupt service routine. This routine is written in AVR Assembly where I just wrote:
...
3
votes
2
answers
4k
views
Interrupt Management - Large AVR Projects
This is for the more experienced one's out there.
I am currently involved with a large AVR project (using ATMega328) and it's getting confusing with respect to interrupts.
The project involves ...
3
votes
4
answers
17k
views
AVR SPI target with interrupt
For a project, I want to have two microcontrollers talk to each other via an SPI interface. I wrote the following code for the target microcontroller:
...
3
votes
2
answers
2k
views
Understanding volatile class fields in AVR C++ programs
I'm having some confusion about what members to declare volatile in a program I'm writing in C++ for an AVR microcontroller, with interrupts. When it's plain C it makes sense - the compiler doesn't ...
3
votes
4
answers
4k
views
Arduino interrupts for button input
I have 6 buttons on my printed board, and I'd like to use interrupts on them all, but they don't correspond to the interrupts listed on the specs.
Is it true that you cannot choose arbitrary pins to ...
3
votes
1
answer
3k
views
Clearing Flag Bits By Writing 1
Most of the interface devices have various flag bits (that can also raise interrupts if that functionality is provided) used to check the status of the device/operation.
Usually they are cleared by ...
3
votes
1
answer
1k
views
AVR external interrupt triggering by the falling edge: for how long should I keep signal low to guarantee triggering?
The question header appeared to bee too long. I'm sorry for that.
So I have a schematic generating a short LOW on INT0 pin of ATmega48PA. From the simulation I figured out that the LOW level will be ...
3
votes
2
answers
2k
views
Timer0 overflow interrupt does not work on ATtiny10
I am trying to use the Timer0 overflow interrupt to make a little project.
I used such a timer in the ATtiny45 and it worked, but with ATtiny10 no result.
So I tried an easy LED blinking program and ...
3
votes
1
answer
272
views
AVR diagram of functions calling, ISR and main loop share the same resource
I made a simple diagram of functions calls to illustrate the potential problem which bothering me a little. As you can see, my task_list (which is simple linked ...
3
votes
1
answer
2k
views
AVR USART Random Behaviour
I seem to be getting random character in my USART output with an ATMEGA8
uart.c
...
3
votes
2
answers
7k
views
Use PWM and ISR at same time on AVR
Is it possible to use AVR PWM outputs and ISR interrupts at the same time?
I've got a project I'm trying to do on an ATMega328P and I need 3 PWM outputs but ALSO need to be able to use ISR interrupts ...
3
votes
2
answers
2k
views
avr-gcc timer overflow interrupt handler in inline assembly
My current project involves producing 200KHz PWM waveforms using timer 1 in fast PWM mode. I would like to increment a 16-bit counter every time the timer overflows (every 5μS)
...
3
votes
1
answer
5k
views
AVR Measuring frequency using external interrupt - where are my cycles going?
I'm using an external interrupt to measure the frequency of a signal, the AVR clock is at 8MHz. I'm essentially counting the ticks between pin toggles using a 16 bit timer (with some handling for ...
3
votes
2
answers
325
views
Setting port in main loop causes ISR to starve
The example code
initializes an asynchronous timer that is fired every second
sets two ports as outputs (PA4, PA6 - LEDs connected)
the timer ISR toggles pin PA4
permanently sets pin PA6 to 1 in the ...
3
votes
0
answers
430
views
ISR won't modify a global variable (IAR)?
First, some background on what I'm working on.
I have a custom board with ATmega324A that I designed as part of a project I'm working on. Originally, software for the uC was written for GCC in Atmel ...
2
votes
1
answer
9k
views
Global variable in AVR interrupt routine
I am writing a code with interrupt routine. For debugging the code am using UART. So, here is the snippet:
...
2
votes
2
answers
9k
views
How many external interrupts has attiny85?
The title is quite self descriptive. I ask this question because I found contradicting information in the atmel web page. I need two external interrupts to control one rotary encoder. One interrupt ...
2
votes
2
answers
1k
views
Can't trigger AVR ADC Interrupt
I am using an Atmel's XPlained mini board with Atmega328PB. I am trying to use ADC interrupt, however I can't get it to fire. Here's the code that I have a problem with:
...
2
votes
1
answer
2k
views
AVR: why each Interrupt Vector occupies two instruction words
During my study of Atmega328 datasheet I found that each interrupt vector occupies two addresses and after searching i can not find why that.
That is a screen shot from atmega328p datasheet page 82
2
votes
2
answers
2k
views
Missed Interrupt Problem with Attiny85
I'm trying to use an Attiny85 (digispark) to wake another controller from sleep (an ESP8266).
The Attiny is connected to an IR receiver which has an active low output. Basically I have connected an ...
2
votes
1
answer
20k
views
AVR Timer1 OCR1A controls TIMER1_COMPB_vect interrupt!
I was struggling with timer interrupts in my project. I couldn't make it work properly. So I decided writing a simple code and I saw a very interesting case.
...
2
votes
2
answers
18k
views
Toggle OC1A, OC1B and OC1C using timer in CTC mode
Most AVR microcontrollers got three dedicated pins for each timer (for example, OC1A, OC1B, and OC1C) that can be toggled automatically when the counter reaches the so called top value in the ...