本帖最后由 小小电子爱好者 于 2018-10-17 10:13 编辑
8位可以数据分配
u8 xdata HC595_Write_Buffer[2];
u8 xdata SMG_Duan_Buffer[20]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0xbf,0xff,0x89,0xC7};
u8 xdata SMG_Wei_Buffer[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
u8 xdata SMG_Write_Buffer[8];
void HC595_Init()
{
HC595_DS=1;
HC595_SH=1;
HC595_ST=1;
}
void HC595_Write_Driver()
{
u8 i;
HC595_DS=1;
HC595_SH=1;
HC595_ST=0;
for(i=0;i<8;i++)
{
HC595_SH=0;
HC595_DS=HC595_Write_Buffer[1]&0x80;
HC595_Write_Buffer[1]<<=1;
HC595_SH=1;
}
for(i=0;i<8;i++)
{
HC595_SH=0;
HC595_DS=HC595_Write_Buffer[0]&0x80;
HC595_Write_Buffer[0]<<=1;
HC595_SH=1;
}
HC595_ST=1;
HC595_DS=1;
HC595_ST=0;
}
void SMG_Display_Ser()
{
static u16 xdata count=0;
switch(count/10)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
HC595_Write_Buffer[0]=SMG_Wei_Buffer[count/10];
HC595_Write_Buffer[1]=SMG_Duan_Buffer[SMG_Write_Buffer[count/10]];
HC595_Write_Driver();
break;
}
count++;
count%=80;
}
void SMG_Ser()
{
SMG_Write_Buffer[0]=(u16)0%10;
SMG_Write_Buffer[1]=(u16)0/10%10;
SMG_Write_Buffer[2]=(u16)0/100%10;
SMG_Write_Buffer[3]=16;
SMG_Write_Buffer[5]=(u16)0%10;
SMG_Write_Buffer[6]=(u16)0/10%10;
SMG_Write_Buffer[7]=(u16)0/100%10;
SMG_Write_Buffer[8]=16;
SMG_Display_Ser();
}
|