进入第2步数码管动态刷新显示01234567
0赞
先上代码,高手勿喷
记录我学习的点滴过程,完成用定时中断动态刷新数码管显示01234567,方法有点笨望请原谅
/*
MCU:STC89C52RC
Fosc:11059200Hz
2014-04-27
坎悟积验
*/
#include <reg52.h>
typedef unsigned char Uint8;
typedef unsigned int Uint16;
typedef unsigned long Uint32;
Uint8 code shuLED[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x80};
#define Pro0 P0
sbit DULA = P1^7;
sbit WELA = P1^6;
Uint8 i = 0;
//Uint8 tab[8] = {0};
//Uint32 tim = 0;
void main()
{
// tim = 91234567;
// tab[0] = tim/10000000;
// tab[1] = tim%10000000/1000000;
// tab[2] = tim%1000000/100000;
// tab[3] = tim%100000/10000;
// tab[4] = tim%10000/1000;
// tab[5] = tim%1000/100;
// tab[6] = tim%100/10;
// tab[7] = tim%10;
TMOD = 0x01;
TH0 = 0xfc;
TL0 = 0x66;
EA = 1;
ET0 = 1;
TR0 = 1;
while(1);
}
void time0() interrupt 1
{
TH0 = 0xfc;
TL0 = 0x66;
i++;
switch(i)
{
case 1: {
WELA = 1;
Pro0 = 0xfe;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[0];
DULA = 0;
Pro0 = 0xff;
};break;
case 2: {
WELA = 1;
Pro0 = 0xfd;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[1];
DULA = 0;
Pro0 = 0xff;
};break;
case 3: {
WELA = 1;
Pro0 = 0xfb;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[2];
DULA = 0;
Pro0 = 0xff;
};break;
case 4: {
WELA = 1;
Pro0 = 0xf7;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[3];
DULA = 0;
Pro0 = 0xff;
};break;
case 5: {
WELA = 1;
Pro0 = 0xef;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[4];
DULA = 0;
Pro0 = 0xff;
};break;
case 6: {
WELA = 1;
Pro0 = 0xdf;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[5];
DULA = 0;
Pro0 = 0xff;
};break;
case 7: {
WELA = 1;
Pro0 = 0xbf;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[6];
DULA = 0;
Pro0 = 0xff;
};break;
case 8: {
WELA = 1;
Pro0 = 0x7f;
WELA = 0;
Pro0 = 0xff;
DULA = 1;
Pro0 = shuLED[7];
DULA = 0;
Pro0 = 0xff;
};break;
}
if(i == 9)i = 0;
}
为什么图片传不上去?我好郁闷
