这是一个七段数码管显示的程序(共阴极),有些地方不太明白,烦各位说一下
#include <reg51.h>
#include <stdio.h>
#include <math.h>
#include <absacc.h>
#define DIGPORT XBYTE[0x0200] /*定义字位口*/
#define WORDPORT XBYTE[0x0100] /*定义字型口*/
#define fosc 11.0592 /*晶振频率*/
#define time0 2000 /*定时2000us*/
#define uchar unsigned char
uchar digbit; //字位
uchar wordbuf[4]; //字型码缓冲区
uchar idata time0_tmp; //临时变量,用于计算定时
uchar getcode(uchar i); //根据共阴极字型码表获取字型码
void display(void); //显示函数
/*Ö÷º¯Êý*/
void main()
{
DIGPORT=0; //关闭显示(不是为高电平才不亮的吗?)
TMOD=0x01; //T0工作方式1
/*2ms定时设置*/
time0_tmp=65535-time0*fosc/12;
TH0=(time0_tmp/256);
TL0=(time0_tmp%256);
TR0=1; //定时器0为运行状态
ET0=1; //??(这里设为允许中断后就去执行中断函数吗?) 定时器0中断允许
EA=1; //所有中断允许