點(diǎn)陣調(diào)試(附程序)
//函數(shù)聲明;本文引用地址:http://m.butianyuan.cn/article/201611/322947.htm
void HC595_CD(uint Value); //595驅(qū)動函數(shù);
void main()
{
uint i = 0;
//P2=tableLie[0];
//HC595_CD(tableHng[0]);
//uint Value;
//P2=0xfd;
//Value = 0x01;
//HC595_CD(Value);
timer0_initialize();
while(1)
{
{
HC595_CD(tableHng[i]);
}
{
HC595_CD(table1[i]);
}
{
HC595_CD(table2[i]);
}
{
HC595_CD(table3[i]);
}
{
HC595_CD(table4[i]);
}
{
HC595_CD(table5[i]);
}
{
HC595_CD(table6[i]);
}
{
HC595_CD(table7[i]);
}
{
HC595_CD(table8[i]);
}
{
HC595_CD(table9[i]);
}
}
}
static void timer0_isr(void) interrupt 1 //定時器里避免放大的延時函數(shù) 以免發(fā)生錯誤
{
time++;
TR0=0;
TL0=(0X78);
TH0=(0X0C);
TR0=1;
if(time==50)
{
}
}
//74HC595驅(qū)動函數(shù);
//功能:把輸入的數(shù)據(jù)輸出到對應(yīng)的引腳上;
//輸入函數(shù):Value
void HC595_CD(uint Value)
{
uint
OE = 1; //芯片輸出關(guān)閉;
MR = 0; //IC復(fù)位;
MR = 1; //復(fù)位結(jié)束;
for(i = 0; i < 8; i++) //傳送8位數(shù)據(jù);
{
DS = Value&0x01; //并行數(shù)據(jù)轉(zhuǎn)串行;
SH_CP = 0; //移位寄存器時鐘為0;
ST_CP = 0; //存儲寄存器時鐘為0;
_nop_();
_nop_();
_nop_(); //短延時;
_nop_();
Value >>= 1; //數(shù)據(jù)移位;
SH_CP = 1; //產(chǎn)生移位脈沖;
ST_CP = 1;
}
OE
}
評論