____________________________________________________________________________________________________
Vector no Program address source Interrupt detail Interrupt name(used in programming) 1 0000 RESET Power on RESET Not programmable 2 0002 INT0 External interrupt 0 INT0_vect 3 0004 INT1 External interrupt 1 INT1_vect 4 0006 INT2 External interrupt 2 INT2_vect 5 0008 TIMER2 COMP Timer/counter2 compare match TIMER2_COMP_vect 6 000A TIMER2 OVF Timer/counter2 overflow TIMER2_OVF_vect 7 000C TIMER1 CAPT Timer/counter1 capture event TIMER1_CAPT_vect 8 000E TIMER1 COMPA Timer/counter1 compare match A TIMER1_COMPA_vect 9 0010 TIMER1 COMPB Timer/counter1 compare match B TIMER1_COMPB_vect 10 0012 TIMER1 OVF Timer/counter1 overflow TIMER1_OVF_vect 11 0014 TIMER0 COMP Timer/counter0 compare match TIMER0_COMP_vect 12 0016 TIMER0 OVF Timer/counter0 overflow TIMER0_OVF_vect 13 0018 SPI, STC Serial transfer complete SPI_STCvect 14 001A USART, RXC USART, Rx complete USART0_RX_vect 15 001C USART, UDRE USART, data register empty USART0_UDRE_vect 16 001E USART, TXC USART, Tx complete USART0_TX_vect 17 0020 ADC ADC conversion complete ADC_vect 18 0022 EE_RDY EEPROM ready EE_RDY_vect 19 0024 ANA_COMP Analog comparator ANALOG_COMP_vect 20 0026 TWI Two wire serial interface TWI_vect 21 0028 SPM_RDY Stored program memory ready SPM_RDY_vect LCD.H ________________________________________________________________________________________________________________________________________ Content for the tab VIDEO
Click Here : understanding of interrupt as program point of view
1. PROGRAM OF EXTERNAL INTERRUPTS IN ATMEGA16, INT0 CONTROL LCD AND INT2 CONTROL LED BLINKING
/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- INTO CONTROL LCD AND INT1 CONTROL LED BLINKING
******************************************************/
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
#include"lcd.h"
void main()
{
sei(); // globle interrupt enable
MCUCSR=0x40;
MCUCR=0X04;
GICR|=(1<<INT1)|(1<<INT2); // interrupt 1 is enable
DDRB=0x00; // PORTB is in output mode
DDRD=0XF7;
DDRA=0XFF;
/* pin 4 is act as input and rest of pin act as ouput*/
init_LCD();
while(1)
{
PORTA=0X0F; // led is on
_delay_ms(50);
PORTA=0X00; // led is off
_delay_ms(50);
}
}
ISR (INT1_vect)
{
int i=10;
while(i--)
{
dis_cmd(0X01); // clear lcd
LCD_write_string("ISR INTERRUPT 1.........");
}
}
ISR (INT2_vect)
{
int i=50;
while(i--)
{
PORTA=0XF0; // led is on
_delay_ms(50);
PORTA=0X00; // led is off
_delay_ms(50);
}
}
/*LCD.H HEADER FILE*/
#define ctrl PORTD
#define en 2 // enable signal
#define rw 1 // read/write signal
#define rs 0 // register select signal
void init_LCD(void)
{
dis_cmd(0x02); // to initialize LCD in 4-bit mode.
_delay_ms(1);
dis_cmd(0x28); //to initialize LCD in 2 lines, 5X7 dots and 4bit mode.
_delay_ms(1);
dis_cmd(0x01); // clear LCD
_delay_ms(1);
dis_cmd(0x0E); // cursor ON
_delay_ms(1);
dis_cmd(0x80); // —8 go to first line and –0 is for 0th position
_delay_ms(1);
return;
}
void dis_cmd(char cmd_value)
{
char cmd_value1;
cmd_value1 = cmd_value & 0xF0; //mask lower nibble
//because PA4-PA7 pins are used.
LCD_cmd(cmd_value1); // send to LCD
cmd_value1 = ((cmd_value<<4) & 0xF0); //shift 4-bit and
//mask
LCD_cmd(cmd_value1); // send to LCD
}
void dis_data(char data_value)
{
char data_value1;
data_value1=data_value & 0xF0;
LCD_write(data_value1);
data_value1=((data_value<<4) & 0xF0);
LCD_write(data_value1);
}
void LCD_cmd(unsigned char cmd)
{
ctrl=cmd;
ctrl&=~(1<<rs);
ctrl&=~(1<<rw);
ctrl|=(1<<en);
_delay_ms(1);
ctrl&=~(1<<en);
_delay_ms(10);
return;
}
void LCD_write(unsigned char data)
{
ctrl= data;
ctrl|=(1<<rs);
ctrl&=~(1<<rw);
ctrl|=(1<<en);
_delay_ms(1);
ctrl&=~(1<<en);
_delay_ms(10);
return ;
}
void LCD_write_string(unsigned char *str) //store address value of the string in pointer *str
{
int i=0;
while(str[i]!='\0') // loop will go on till the NULL character in the string
{
dis_data(str[i]); // sending data on LCD byte by byte
i++;
}
return;
}
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)