8051/8052系列单片机标准向量表:
中断号描述地址
0外部中断00003h
1定时/计数器0000Bh
2外部中断10013h
3定时计数器1001Bh
4串口0023h
5定时计数器2(8052)002Bh
众多厂商为其51系列单片机添加了更多的中断。Keil Cx51编译器支持多达32个中断函数(中断号0-31)。下表列出了这32个中断向量入口地址:
中断号 入口地址 00003h1000Bh20013h3001Bh40023h5002Bh60033h7003Bh80043h9004Bh100053h11005Bh120063h13006Bh140073h15007Bh中断号 入口地址 160083h17008Bh180093h19009Bh2000A3h2100ABh2200B3h2300BBh2400C3h2500CBh2600D3h2700DBh2800E3h2900EBh3000F3h3100FBh
函数声明时使用interrupt关键词,该函数将被编译器视为中断服务程序,例如:
unsigned int interruptcnt;
unsigned char second;
void timer0 (void) interrupt 1 using 2 {
if (++interruptcnt == 4000) {
second++;
interruptcnt = 0;
}
}
interrupt 关键词后跟一个整数,表示中断号,取值范围0-31。中断号必须为常数,不允许使用操作符表达式。
int