问题:摁下中断按钮外部中断没反应,下面是硬件电路
#include "mega16.h"
#define uchar unsigned char
#define button1 PIND.2
#define button2 PIND.3
#define sounder PORTD.0
int a;
flash uchar tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
flash uchar tab2[]={0xf0,0x0f,0xf0,0x0f,0xf0,0x0f};
void delay (int k)
{
int i,j;
for(i=0;i<k;i++)
for(j=0;j<1140;j++);
}
interrupt[EXT_INT0]void int0()
{
int i;
for(i=0;i<500;i++)
{
sounder=1;
delay(2);
sounder=1;
delay(2);
}
}
interrupt[EXT_INT1]void int1()
{
int i,j;
a++;
#asm("sei")
if(a%2==0)
{
for(i=0;i<6;i++)
{
tab2[i];
delay(5);
}
}
else
for(j=0;j<24;j++)
{
tab[j];
delay(5);
}
}
void main()
{
DDRC=0xff;
PORTC=0xff;
DDRD=0xf3;
PORTD=0xff;
MCUCR=0x0a;
GICR=0xc0;
#asm("sei")
while(1)
{
PORTC=0xff;
delay(500);
PORTC=0x00;
delay(500);
}
}
|