请标注代码的标注:#include <REGX52.H> typedef unsigned int u16; typedef unsigned char u8; #define SMG_A_DP_PORT P0 u8 gsmg_code[8]={0x3f,0x00,0x03,0x06, 0x0c,0x18,0x30,0x21}; int x=1; void delay_10us(u16 ten_us) { while(ten_us--); } int0_srv()interrupt 0{ x=x+1; delay_10us(20000); } int1_srv()interrupt 2{ if (x!=0) {x=0;} else {x=1;} delay_10us(20000); } void main() { IE=0x85; while(1) { if(x<=7) {SMG_A_DP_PORT=gsmg_code[x];} else{x=2;} } }
时间: 2024-02-29 17:57:18 浏览: 26
// 引入头文件
#include <REGX52.H>
// 定义数据类型
typedef unsigned int u16;
typedef unsigned char u8;
// 定义端口
#define SMG_A_DP_PORT P0
// 数码管显示的编码
u8 gsmg_code[8]={0x3f,0x00,0x03,0x06,0x0c,0x18,0x30,0x21};
// 定义变量
int x=1;
// 延时函数
void delay_10us(u16 ten_us) {
while(ten_us--);
}
// 外部中断0服务函数
int0_srv()interrupt 0{
x=x+1;
delay_10us(20000);
}
// 外部中断1服务函数
int1_srv()interrupt 2{
if (x!=0) {x=0;}
else {x=1;}
delay_10us(20000);
}
// 主函数
void main() {
// 开启外部中断0和1
IE=0x85;
while(1) {
if(x<=7) {SMG_A_DP_PORT=gsmg_code[x];}
else{x=2;}
}
}
相关问题
#include<REGX51.H> #include<intrins.h> #define uchar unsigned char #define uint unsigned int什么意思
这段代码是一个基于51单片机的C语言程序,其中:
- `#include<REGX51.H>` 是包含了51单片机的头文件,可以使用其中定义的寄存器及功能;
- `#include<intrins.h>` 是包含了汇编语言的头文件,可以使用其中定义的内嵌汇编函数;
- `#define uchar unsigned char` 定义了一个名为`uchar`的宏,表示无符号字符类型;
- `#define uint unsigned int` 定义了一个名为`uint`的宏,表示无符号整数类型。
#include <REGX52.H>跟#include<Reg52.h>
这两个头文件都是51单片机的头文件,但是它们的文件名大小写不同。其中,`#include <REGX52.H>`是一些厂家提供的头文件,而`#include<Reg52.h>`是Keil提供的头文件。两个头文件的功能是相同的,都可以用于51单片机的编程。因此,你可以根据自己的需要选择其中一个头文件进行使用。