16x16點陣,STC89C52,74HC595,74HC154
由于本人小白,剛開始學習單片機。請各位幫我看一下,那里出錯了,測試失敗,多謝!
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit ds=P3^2;
sbit sc=P3^3;
sbit st=P3^4;
uchar e=0;
uchar data table[]=
{ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,};
uchar code zhimo[]=
{//你
0x00,0x01,0x06,0x1f,0xe0,0x02,0x04,0x18,0xf0,0x10,0x13,0x10,0x10,0x14,0x18,0x00,
0x80,0x00,0x00,0xff,0x00,0x08,0x30,0xc0,0x02,0x01,0xfe,0x00,0x80,0x60,0x18,0x00,
};//縱向取模字節正序
void datbyte(uchar dat);
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
TMOD=1;
TH0=(65536-2500)/256;
TL0=(65536-2500)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
datbyte(~zhimo[e+16]);
datbyte(~zhimo[e]);
st=0;
delay(5);
st=1;
P2=table[e];
delay(20);
}
}
void timer0() interrupt 1
{
TH0=(65536-2500)/256;
TL0=(65536-2500)%256;
e++;
if(e==17)
{
e=0;
}
}
void datbyte(uchar dat)//一個字節傳輸函數
{
uchar a;
st=1;
sc=1;
for(a=0;a<8;a++)
{
ds=dat>>7;
dat<<=1;
sc=0;
_nop_();
_nop_();
sc=1;
}
}
|