#define dissetmode 0x02
#define writedatamode_z 0x40
#define writeledmode_z 0x41
#define readkeymode 0x42
#define readswmode 0x43
#define writedatamode_g 0x44
#define writeledmote_g 0x45
#define startaddress 0xc0
#define disconmode 0x8f
#define uchar unsigned char
uchar a[]={ c_7SEG_0,c_7SEG_1,c_7SEG_2,c_7SEG_3,c_7SEG_4,c_7SEG_5,c_7SEG_6,c_7SEG_7,c_7SEG_8,c_7SEG_9,
c_7SEG_A,c_7SEG_B,c_7SEG_C,c_7SEG_D,c_7SEG_E,c_7SEG_F,
c_7SEG_LINE,c_7SEG_H,c_7SEG_NOP,c_7SEG_L,c_7SEG_N,c_7SEG_U,c_7SEG_C};
unsigned long TmData = 0;
unsigned int i;
#define STB PB0
#define CLK PB1
#define DIN PB2
void indate(unsigned char p)
{
unsigned int i;
STB=0;
for(i=0;i<8;i++)
{
CLK=0;
if((p&0x01)!=0)
{
DIN=1;
}
else
{
DIN=0;
}
_nop_();_nop_();
CLK=1;
p=p>>1;
}
_nop_();_nop_();
}
void TM1620_Display(void)
{
uchar temp[4];
temp[3]=TmData%10000/1000;
temp[2]=(TmData%1000/100);
temp[1]=TmData%100/10;
temp[0]=TmData%10;
DIN=1;
CLK=1;
STB=1;
indate(dissetmode);
STB=1;
indate(writedatamode_g);
STB=1;
for(i=0;i<4;i++)
{
if(i==0)
{
indate(startaddress+0x08);
}
else if(i == 1)
{
indate(startaddress+0x04);
}
else if(i == 2)
{
indate(startaddress+0x06);
}
else if(i == 3)
{
indate(startaddress+0x02);
}
indate(a[temp[i]]);
STB=1;
}
for(i = 5;i<=6;i++)
{
if(i == 5)
{
indate(startaddress+0x00);
indate(COM5_DATA);
STB=1;
}
else if(i == 6)
{
indate(startaddress+0x0A);
indate(COM6_DATA);
STB=1;
}
}
indate(disconmode);
STB=1;
}
|