|
正好我手上有这类代码,呵呵
U8 code dis_code[] =
{
0x5f,0x44,0x9d,0xd5,0xc6,0xd3,0xdb,0x45, //0-7
0xdf,0xd7,0xcf,0xda,0x1b,0xdc,0x9b,0x8b, //8-F
0x1a,0xce,0x5e,0x8f,0x80,0x20 //L H U P - .
};
void main(void)
{
Init();
while(1)
{
}
}
/***************************************************************/
/*** Init() **************************************/
/*** 初始化函数 ****************************************/
/*** ****************************************/
/***************************************************************/
void Init(void)
{
/*50ms定时设置*/
TH0 = -DELAY_CONST/256;
TL0 = -DELAY_CONST%256;
/*启动计数器0,关闭计数器1*/
TR0 = 1;
ET0 = 1;
}
/***************************************************************/
/*** Timer0_int() *************************/
/*** 定时器0 中断响应函数 *************************/
/*** 2007.01.09 *************************/
/***************************************************************/
void Timer0_int(void) interrupt 1
{
//重置定时0
TH0 = -DELAY_CONST/256;
TL0 = -DELAY_CONST%256;
Display();//调用显示函数
led_index++;
led_index &= 0x07;
}
/***************************************************************/
/*** Display() ********************************/
/*** 刷新一位显示 ********************************/
/*** 全局变量 display_index ********************************/
/*** 2007.01.09 ********************************/
/***************************************************************/
void Display(void)
{
switch (led_index)
{
case 0:
LED8 = 1;
LEDD = m_dis[0];
LED1 = 0;
break;
case 1:
LED1 = 1;
LEDD = m_dis[1];
LED2 = 0;
break;
case 2:
LED2 = 1;
LEDD = m_dis[2];
LED3 = 0;
break;
case 3:
LED3 = 1;
LEDD = m_dis[3];
LED4 = 0;
break;
case 4:
LED4= 1;
LEDD = m_dis[4];
LED5 = 0;
break;
case 5:
LED5 = 1;
LEDD = m_dis[5];
LED6 = 0;
break;
case 6:
LED6 = 1;
LEDD = m_dis[6];
LED7 = 0;
break;
case 7:
LED7= 1;
LEDD = m_dis[7];
LED8 = 0;
break;
}
} |
|