用 AVR Studio 6 环境编译一个外部中断小程序,完全按照书上程序输入的,可编译不通过,提示:
Warning:'SIG_INTERRUPT0'appears to be a misspelled signal handler[enabled by default]
Error:attempt to use poisoned "SIG_INTERRUPT0"
#include <avr/io.h>
#include <avr/interrupt.h> //使用中断必须添加
#include <util/delay.h> //使用延时必须添加
#define uchar unsigned char
#define uint unsigned int
SIGNAL(SIG_INTERRUPT0) //外部中断0的中断处理
{
_delay_ms(10); //延时去抖
if((PIND & _BV(PD0)) == 0)
PORTC |= (1<<PC0); //点亮灯
while(!((PIND & _BV(PD0)))); //等待按键释放
PORTC &=~ _BV(PD0); //熄灭灯
}
int main(void)
{
DDRC = _BV(PC0);
PORTC &= ~_BV(PC0); //输出低电平,熄灭灯
EICRA = 0x02;
EIFR = (1<<INTF0);
EIMSK = 0x01;
sei();
while(1); //等待中断发生
}
|