Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to use dual interrupt in AVR?

Status
Not open for further replies.

Elits

Member level 4
Member level 4
Joined
Jul 27, 2005
Messages
79
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Indonesia
Activity points
1,982
avr interrupts

Hi all,
I want to know how to use double interrupt in AVR (ATmega8515L)?i use INT0 and serial , so howto configure it? i choose INT0 as high priority?could u give some reference?
thanks...

Elits
 

avr nested interrupt

It's all in the datasheet.

You can't choose INT0 as high priority just because it's already choose by default. You don't have control on priority level. It's hardware defined.
The list on page 53 of the datasheet determines the priority levels of different interrupts. The lower the address the higher is the priority level. RESET has the highest priority and the next is INT0 - the External Interrupt Request 0. Obvious SPM_RDY has less priority level among all.
Let's assuming the following program flow.
A serial interrupt occurs due to a received character, the current program counter value is saved in the stack and loaded with appropiate vector interrupt value $0009 and your Serial RX ISR is executed now.
The Global Interrupt Enable I-bit is cleared and all interrupts are disabled.
If INT0 occurs, it won't be served now, but the corresponding interrupt flag remembered until the general interrupt is enabled again.
It's place in so called pending queue.
Hey!, but INT0 has higher priority level than Serial Interrupt ! How comes that ?
Well, that's the way AVR handles interrupts. If you're a gentleman and want your Serial ISR being interrupt by INT0 pending interrupt, you can enable interrupts by writing logic "1" to the I-bit (or performing a SEI instruction) and the higher priority INT0 is allowed to be served during your Serial ISR.
This is what is called a nested interrupt.
Obvious if you don't want that, the INT0 interrupt must wait until your Serial Int is finished with a RETI instruction (which enables again the interrupts).

To resume, the priority level does matter only when more interrupts occurs in the same time or are waiting to be served from the pending queue.
If you're executing Serial ISR and INT0 and INT1 occurs, then after your return from Serial ISR, the level of priority is checked and INT0 which has higher priority than INT1 is served first.

This is a first type of interrupt, the ones triggered by an event that sets the coresponding interrupt flag.
There are another type of interrupts that will trigger as long as the interrupt condition is present. These interrupts don't necessarily have Interrupts Flags.
If the interrupt condition dissapears before the interrupt is enabled, the interrupt will not be neither triggered nor remembered.

You can ask what kind of interrupts are these ? You're more familiar with the interrupts that are served immediately as they appear due to the natural means of word interrupt: You must interrupt all you're doing now and respond to my querry since I can't wait, it's urgent !
Or triggered events interrupts occuring during execution of time critical routines (like performing a EEPROM data store due to a imminent power fall when you don't want to be interrupted - executing a CLI will disable the interrupts) that must be remembered and served after.

When the External Interrupt is enabled and configured as level triggered (only INT0/INT1), rather than triggered by a falling or raising edge, the interrupt will trigger as long as the pin is held at low level. It won't set the Interrupt Flag even if appears on INT0 pin !
It will not be remembered that occured, too. Thus, if you're bussy you can missed it. It's this an interrupt ? You got to be kidding !
Yes, it's an interrupt in respect to the meaning of the word. The problem is what you're doing when this signal appears. When you're doing NOTHING and this signal appears, it's called interrupt too, because it's knocking at your door.
How can you do NOTHING ? It's a joke ? No isn't. The microcontroller could go asleep. Don't you want to wake up ? You can call this interrupting him !
Now remember that recognition of falling or rising edge interrupts on INT0 or INT1 requires the presence of an I/O clock that is halted in all sleep modes but idle mode.
You're in a sleep mode and all external activities must be detected asynchronously, which level interrupts on INT0/INT1 are. This implies that these interrupts can be used for waking the micro also from sleep modes other than idle mode.

Until you'll program the BOOTRST fuse and set IVSEL bit in GICR this is all you have to know about interrupt.

Don't forget to:
1. Set your pointer stack (SPL SPH) to point above $60 (use RAMEND as per numerous examples)
2. Set the I-bit from SREG to enable interrupts
3. Set the coresponding bit for your INT0 or Serial Interrupts or whatever interrupt you wish to use
4. Write your program using the general program setup for Interrupt Vector Addresses as per page 54 of datasheet (using ORG is recommended).
5. Don't forget to use the RETI at the end of your ISR

ISR means Interrupt Service Routine. I know you would like to ask.

I apologize if my explanations are leaving more confused that you're now, but at least I've tried.

An more genuine english style.
Go to **broken link removed** and register.
Then read all 7 lessons at : Basic interrupts and I/O https://www.avrfreaks.net/index.php?module=dpDocs&func=display&mid=68
 

avr serial interrupt

how i can gets points ??? i need 1 point
 

avr programming, interrupts

if you are using a c compiler like codevision or ICC AVR they have a code wizard that will set all prephierals for you download the demo version of them and give them a try
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top