#include
#include
#define uchar unsigned char
#define uint unsigned int
#define NOP _nop_()
sbit OE = P2^0;
sbit A1 = P2^1;
sbit B1 = P2^2;
sbit SHCP=P2^4; //11脚SHCP 移位时钟
sbit STCP=P2^3; //12脚STCP 锁存时钟
sbit DATA=P3^7; //数据输入
uchar code table[10][32]=
{{0xFE,0xF7,0xBD,0xF7,0xC8,0x77,0xDB,0x77,0xF8,0x01,0xFB,0x77,0x18,0x37,0xDB,0x57,
0xD0,0x57,0xDE,0x77,0xDD,0x77,0xD5,0x77,0xCB,0x77,0xD7,0x77,0xED,0x57,0xFE,0xEF},
{ 0xFE,0xF7,0xBD,0xF7,0xC8,0x77,0xDB,0x77,0xF8,0x01,0xFB,0x77,0x18,0x37,0xDB,0x57,
0xD0,0x57,0xDE,0x77,0xDD,0x77,0xD5,0x77,0xCB,0x77,0xD7,0x77,0xED,0x57,0xFE,0xEF}};
/*******************************************************************************************/
/*******************************************************************************************/
/*******************************************************************************************/
//数据串行输入
void serial_input(uchar dat)
{
uint m;
for(m=0;m<8;m++)
{
if(dat & 0x80)
DATA=1;
else
DATA=0;
SHCP=0;
SHCP=1;
NOP;
NOP;
SHCP=0;
NOP;
NOP;
dat=dat<<1;
}
}
/*******************************************************************************************/
//并出
void serial_output()
{
STCP=1;
NOP;
NOP;
STCP=0;
}
/*******************************************************************************************/
/*******************************************************************************************/
//行显控制
void HC138_scan(uchar temp)
{
OE=1;
A1=0x01 & temp;
B1=0x01 &(temp>>1);
}
/*******************************************************************************************/
/*******************************************************************************************/
//整屏显示
void display()
{
uint i,j,k;
for(k=0;k<4;k++) //显示的四行
{
for(j=0;j<2;j++) //显示3、4列
{
for(i=0;i<2;i++) // 显示1、2列
{
serial_input(table[j][3*8+2*k+i]);
serial_input(table[j][2*8+2*k+i]);
serial_input(table[j][1*8+2*k+i]);
serial_input(table[j][0*8+2*k+i]);
}
}
serial_output();
HC138_scan(k);
}
}
/*******************************************************************************************/
/*******************************************************************************************/
/*******************************************************************************************/
/*******************************************************************************************/
void main()
{
while(1)
{
display();
}
}