哪位大神能幫我解釋一下這個MAX7219程序的初始化這一部分程序,這個程序可以驅動8位數碼管亮7位,如果我想改一下應該怎么改?
void sd7219(uchar trans)
{
uchar b;
uchar j;
for(b=0;b<8;b++)
{
_nop_();
LCK=0;
j=trans&0x80;
trans<<=1;
if(j==0x00)
DIN=0;
else
DIN=1;
_nop_();
LCK=1;
_nop_();
}
}
/*****************7219 D′èë×Ö½ú************************/
void w7219(uchar coma,uchar comb)
{
_nop_();
LD=0;
_nop_();
sd7219(coma);
_nop_();
sd7219(comb);
_nop_();
LD=1;
_nop_();_nop_();
LCK=0;
baojing();
key();
}
/*****************7219 初始化ˉ************************/
void init()
{
coma=0x0c;
comb=0x00;
w7219(coma,comb);
delayms(2);
coma=0x0c;
comb=0x01;
w7219(coma,comb);
delayms(2);
coma=0x0b;
comb=0x07;
w7219(coma,comb);
delayms(2);
coma=0x0a;
comb=0x09;
w7219(coma,comb);
delayms(2);
coma=0x09;
comb=0x7f;
w7219(coma,comb);
delayms(2);
coma=0x0f;
comb=0x00;
w7219(coma,comb);
baojing();
key();
}
|