📄 text1.c
字号:
#include <reg51.h>
#include<stdio.h>
Uart_Init();
main()
{ Uart_Init();
EX0=1; /* 打开外部中断0 */
EX1=1; /* 打开外部中断1 */
IT0=1; /* 外部中断0 下降沿触发中断*/
IT1=1; /* 外部中断1 下降沿触发中断*/
EA=1; /* 全局中断允许 */
PX0=0; /* INT0为低优先级 */
PX1=1; /* INT1为高优先级 */
while(1); /* 无限循环 */
}
void int0() interrupt 0 using 0
{ while(1)
{ EA=0; /* 关中断 */
printf("External Interrupt 0 responded\n"); /*响应INT0后不断输出*/
EA=1; /* 开中断 */
}
}
void int1() interrupt 2 using 1
{ printf("External Interrupt 1 responded\n"); /* 响应INT1后输出提示信息 */
}
Uart_Init()
{SCON = 0x52; /* 设置串行口控制寄存器SCON*/
TMOD = 0x20; /* 12M时钟时波特率为2400 */
TCON = 0x69; /* TCON */
TH1 = 0xf3; /* TH1 */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -