Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Prepared by:
Eng. Ashraf Darwish
Ashraf.emad.darwish@gmail.com
Session 4
Interrupts
Introduction:
how does program execution happen ?
program commands are executed one by one
carried out .
Interrupts
Interrupts
completed.
2. The address of the next instruction is stored on
the stack ( apart of chip memory )
3. Address of Interrupt Service Routine (ISR) is
loaded into the program counter.
4. Microcontroller start execute the ISR
5. Program counter loaded with the value stored on
the stack and the program resumed its normal
operation .
Interrupts
Interrupts
Interrupts
External Interrupt
Interrupt registers :
1.
External Interrupt
Interrupt registers :
2.
External Interrupt
Bit 3,2 ISC11 , ISC10 :
For INT1
External Interrupt
Bit 1,0 ISC01 , ISC00 :
For INT0
External Interrupt
Interrupt registers :
3.
For INT2
Bit6 ISC2 :
0
falling edge for INT2
1
Rising edge for INT2
External Interrupt
Interrupt registers :
4.
External Interrupt
Very Important note:
You should set the global interrupt on
in your code as following
#asm(sei)
External Interrupt
Where would I write the code which will
be executed when interrupt occur ?
#include <mega16.h>
Interrupt [EXT-INT0] void ext_in0_isr(void)
{
// write your interrupt code here
}
Void main ( )
{
// write your normal code here
}
Codewizard
Codewizard
see the Attached Tutorial
Thank you
Contact:
http://www.facebook.com/groups/263197427113025
/
Ashraf.darwish@ymail.com
Ashraf.emad.darwish@gmail.com
+201064897791