ATmega32外部中斷嵌套
#include
#pragma data:code
const table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0xff};
#pragma interrupt_handler int0:2
void int0()
{
PORTC&=~BIT(0);
PORTA=table[0];
while(1);
}
#pragma interrupt_handler int1:3
void int1()
{
PORTC&=~BIT(0);
PORTA=table[1];
SEI();
while(1);
}
#pragma interrupt_handler int2:19
void int2()
{
PORTC&=~BIT(0);
PORTA=table[2];
SEI();
while(1);
}
void main()
{
DDRA=0xff;
PORTA=0xff;
DDRC|=BIT(0);
DDRB&=~BIT(2);
PORTB|=BIT(2);
DDRD&=(~BIT(3))&(~BIT(2));
PORTD|=BIT(3)|BIT(2);
SEI();
GICR|=BIT(7)|BIT(6)|BIT(5);
MCUCR|=BIT(3)|BIT(1);
MCUCR&=(~BIT(2))&(~BIT(0));
while(1);
}
評(píng)論