标签:[] void nbsp mod har bsp bit index add
#include <reg52.h>
sbit ADDR0=P1^0;
sbit ADDR1=P1^1;
sbit ADDR2=P1^2;
sbit ADDR3=P1^3;
sbit ENLED=P1^4;
unsigned char LedChar[]={
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
void main()
{
EA=1;
ADDR3=0;
ENLED=0;
TMOD=0x01;
TH0=0xFc;
TL0=0x67;
ET0=1;
TR0=1;
while(1);
}
void InterruptTime() interrupt 1
{
static unsigned char i=0;
static unsigned int cnt=0;
static unsigned int index=0;
static unsigned int tm=0;
TH0=0xFc;
TL0=0x67;
P0=0xFF;
switch(i)
{
case 0:ADDR2=0;ADDR1=0;ADDR0=0;i++;P0=LedChar[0];break;
case 1:ADDR2=0;ADDR1=0;ADDR0=1;i++;P0=LedChar[1+index];break;
case 2:ADDR2=0;ADDR1=1;ADDR0=0;i++;P0=LedChar[2+index];break;
case 3:ADDR2=0;ADDR1=1;ADDR0=1;i++;P0=LedChar[3+index];break;
case 4:ADDR2=1;ADDR1=0;ADDR0=0;i++;P0=LedChar[4+index];break;
case 5:ADDR2=1;ADDR1=0;ADDR0=1;i++;P0=LedChar[5+index];break;
case 6:ADDR2=1;ADDR1=1;ADDR0=0;i++;P0=LedChar[6+index];break;
case 7:ADDR2=1;ADDR1=1;ADDR0=1;i=0;P0=LedChar[7+index];break;
}
cnt++;
if(cnt>=250)
{
cnt=0;
index++;
if(index>=16)
{
index=0;
}
}
}
标签:[] void nbsp mod har bsp bit index add
原文地址:http://www.cnblogs.com/wangjinshan/p/7455120.html