编辑: 笔墨随风 2019-09-28
/* /* Copyright (c) 2004, 通信工程学院戴佳 */ /* All rights reserved.

*/ /* 作者:戴佳 */ /*

4 位8段数码管分别动态显示"1234" , */ #include "7LEDShow.h" void main() { DIGPORT = 0;

// 关闭显示 TMOD = 0x01;

// T0 工作方式

1 /* 2ms 定时设置 */ time0_tmp = 65536-time0*fosc/12;

TH0 = (time0_tmp/256);

TL0 = (time0_tmp%256);

TR0 = 1;

ET0 = 1;

EA = 1;

digbit = 0x01;

// 从第一位数码管开始 wordbuf[3] = 4;

wordbuf[2] = 3;

wordbuf[1] = 2;

wordbuf[0] = 1;

while(1);

} /* 定时器

0 中断服务子程序,定时动态扫描显示 */ void time0_int(void) interrupt

1 { TH0 = (time0_tmp/256);

TL0 = (time0_tmp%256);

display();

}

1 /* 根据共阴极字型编码表获取 0~9,A~B 字型代码 */ uchar getcode(uchar i) { uchar p;

switch (i) { case 0: p=0x3f;

break;

/*

0 */ case 1: p=0x06;

break;

/*

1 */ case 2: p=0x5B;

break;

/*

2 */ case 3: p=0x4F;

break;

/*

3 */ case 4: p=0x66;

break;

/*

4 */ case 5: p=0x6D;

break;

/*

5 */ case 6: p=0x7D;

break;

/*

6 */ case 7: p=0x07;

break;

/*

7 */ case 8: p=0x7F;

break;

/*

8 */ case 9: p=0x67;

break;

/*

9 */ case 10: p=0x77;

break;

/* A */ case 11: p=0x7C;

break;

/* B */ case 12: p=0x39;

break;

/* C */ case 13: p=0x5E;

break;

/* D */ case 14: p=0x79;

break;

/* E */ case 15: p=0x71;

break;

/* F */ default: break;

} return(p);

} /* 显示函数 */ void display(void) { uchar i;

switch (digbit) { case 1: i=0;

break;

case 2: i=1;

break;

case 4: i=2;

break;

case 8: i=3;

break;

default: break;

} DIGPORT = 0;

// 关闭显示 WORDPORT = getcode(wordbuf[i]);

// 送字型码 DIGPORT = digbit;

// 送字位码

2 if (digbit

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题