ORG 0000H
LJMP MAIN
ORG 000BH
LJMP ITOP
ORG 1000H
MAIN: SETB EA
SETB EX0
SJMP $
ITOP: PUSH PSW
PUSH ACC
CPL P1.0
POP ACC
POP PSW
RETI
END
和
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP ITOP
ORG 1000H
MAIN: SETB EA
SETB EX0
HERE: SJMP HERE
ITOP: PUSH PSW
PUSH ACC
INC B
MOV P1,B
POP ACC
POP PSW
RETI
END
回三楼的,给INTO一个单脉冲 申请中断,是人为给的中断,已在试验箱上实验结果正确
第一个:
#include<reg52.h>
main()
{
EA=1;
EX0=1;
while(1);//等待中断
}
void ex0_interrupt(void) interrupt 0 //外中断0处理程序
{
P1^1~=P1^1 //p1.1位取反
}
第二个差不多:
#include<reg52.h>
main()
{
EA=1;
EX0=1;
while(1);
}
void ex0_interrupt(void) interrupt 0
{
B++;
P1=B;
}
#include<reg52.h>
main()
{
EA=1;
EX0=1;
while(1);//等待中断
}
void ex0_interrupt(void) interrupt 0 //外中断0处理程序
{
P1^1~=P1^1 //p1.1位取反
}
第二个差不多:
#include<reg52.h>
main()
{
EA=1;
EX0=1;
while(1);
}
void ex0_interrupt(void) interrupt 0
{
B++;
P1=B;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2009-06-21
1楼已经作答了。
第2个回答 2009-06-21
第一个好像不能中断
#include<reg52.h>
sbit led=P2^0;
sbit led1=P1^1;
void main()
{
EA=1;
EX0=1;
while(1);
led=0;
led1=0;
}
void ex0_interrupt(void) interrupt 1 //外中断0处理程序
{
led1=!led1;//p1.1位取反
}
#include<reg52.h>
sbit led=P2^0;
sbit led1=P1^1;
void main()
{
EA=1;
EX0=1;
while(1);
led=0;
led1=0;
}
void ex0_interrupt(void) interrupt 1 //外中断0处理程序
{
led1=!led1;//p1.1位取反
}