51单片机 16X16点阵 代码程序出问题了,请求帮助、谢谢!!!
#include<reg52.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintsbi...
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit DS = P3^0;
sbit SH_CP = P3^1;
sbit ST_CP = P3^2;
uint code num[5][32]=
{
{0x00,0x7F,0x04,0x04,0x04,0x0F,0x08,0x08,0x10,0x10,0x1F,0x00,0x00,0x00,0xFF,0x00,
0x00,0xFC,0x00,0x00,0x00,0xF0,0x10,0x10,0x10,0x20,0xE0,0x20,0x40,0x40,0xFE,0x00},/*"互",0*/
/* (16 X 16 , 宋体 )*/
{0x08,0x08,0x08,0x08,0xFE,0x08,0x18,0x1C,0x2A,0x2A,0x48,0x88,0x08,0x08,0x08,0x08,
0x00,0xFC,0x84,0x84,0x84,0xFC,0x84,0x84,0x84,0xFC,0x84,0x84,0x84,0x84,0xFC,0x84},/*"相",1*/
/* (16 X 16 , 宋体 )*/
{0x08,0x08,0xFF,0x08,0x7E,0x08,0xFF,0x10,0x20,0x41,0xBF,0x21,0x21,0x21,0x21,0x01,
0x00,0x7C,0x48,0x50,0x48,0x44,0x54,0x48,0x40,0x00,0xF8,0x08,0x08,0x28,0x10,0x00},/*"帮",2*/
/* (16 X 16 , 宋体 )*/
{0x00,0x7C,0x44,0x44,0x44,0x7C,0x44,0x44,0x7C,0x44,0x44,0x44,0x4E,0xF0,0x01,0x02,
0x20,0x20,0x20,0x20,0xFC,0x24,0x24,0x24,0x24,0x24,0x24,0x44,0x44,0x84,0x28,0x10},/*"助",3*/
/* (16 X 16 , 宋体 )*/
{0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",4*/
/* (16 X 16 , 宋体 )*/
};
uint t=0,z=0,temp;
uchar i=0,j=0,k;
void delay (uint ms)
{
uchar t;
while(ms--)for(t = 0;t < 120;t ++);
}
void in_595()
{
uchar i=0;
for(i = 0;i < 16;i ++)
{
temp <<= 1;
DS=CY;
SH_CP = 1;
_nop_();_nop_();
SH_CP = 0;
}
}
void out_595()
{
ST_CP = 0;
_nop_();
ST_CP = 1;
_nop_();
ST_CP = 0;
}
void io_595()
{
in_595();
//_nop_();
out_595();
}
void rwe ()
{
temp = num[z][i*2];
io_595();
temp = num[z][i*2+1];
io_595();
i = i%16;
}
/*void rwe ()
{
temp = num[z][(k+(i*2))%80];
io_595();
temp = num[z][(k+(i*2+1))%80];
io_595();
i = i%16;
}*/
void main ()
{
P3 = 0;
TMOD = 0x01;
TH0 = -4000/256;
TL0 = -4000%256;
IE = 0x82;
TR0 = 1;
while(1);
}
void ET_int () interrupt 1
{
TH0 = -4000/256;
TL0 = -4000%256;
P1 = (P1+1)%16;
rwe();
i++;
if(++t != 600)return;
t = 0;
z = (z + 1)%5;
} 展开
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit DS = P3^0;
sbit SH_CP = P3^1;
sbit ST_CP = P3^2;
uint code num[5][32]=
{
{0x00,0x7F,0x04,0x04,0x04,0x0F,0x08,0x08,0x10,0x10,0x1F,0x00,0x00,0x00,0xFF,0x00,
0x00,0xFC,0x00,0x00,0x00,0xF0,0x10,0x10,0x10,0x20,0xE0,0x20,0x40,0x40,0xFE,0x00},/*"互",0*/
/* (16 X 16 , 宋体 )*/
{0x08,0x08,0x08,0x08,0xFE,0x08,0x18,0x1C,0x2A,0x2A,0x48,0x88,0x08,0x08,0x08,0x08,
0x00,0xFC,0x84,0x84,0x84,0xFC,0x84,0x84,0x84,0xFC,0x84,0x84,0x84,0x84,0xFC,0x84},/*"相",1*/
/* (16 X 16 , 宋体 )*/
{0x08,0x08,0xFF,0x08,0x7E,0x08,0xFF,0x10,0x20,0x41,0xBF,0x21,0x21,0x21,0x21,0x01,
0x00,0x7C,0x48,0x50,0x48,0x44,0x54,0x48,0x40,0x00,0xF8,0x08,0x08,0x28,0x10,0x00},/*"帮",2*/
/* (16 X 16 , 宋体 )*/
{0x00,0x7C,0x44,0x44,0x44,0x7C,0x44,0x44,0x7C,0x44,0x44,0x44,0x4E,0xF0,0x01,0x02,
0x20,0x20,0x20,0x20,0xFC,0x24,0x24,0x24,0x24,0x24,0x24,0x44,0x44,0x84,0x28,0x10},/*"助",3*/
/* (16 X 16 , 宋体 )*/
{0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",4*/
/* (16 X 16 , 宋体 )*/
};
uint t=0,z=0,temp;
uchar i=0,j=0,k;
void delay (uint ms)
{
uchar t;
while(ms--)for(t = 0;t < 120;t ++);
}
void in_595()
{
uchar i=0;
for(i = 0;i < 16;i ++)
{
temp <<= 1;
DS=CY;
SH_CP = 1;
_nop_();_nop_();
SH_CP = 0;
}
}
void out_595()
{
ST_CP = 0;
_nop_();
ST_CP = 1;
_nop_();
ST_CP = 0;
}
void io_595()
{
in_595();
//_nop_();
out_595();
}
void rwe ()
{
temp = num[z][i*2];
io_595();
temp = num[z][i*2+1];
io_595();
i = i%16;
}
/*void rwe ()
{
temp = num[z][(k+(i*2))%80];
io_595();
temp = num[z][(k+(i*2+1))%80];
io_595();
i = i%16;
}*/
void main ()
{
P3 = 0;
TMOD = 0x01;
TH0 = -4000/256;
TL0 = -4000%256;
IE = 0x82;
TR0 = 1;
while(1);
}
void ET_int () interrupt 1
{
TH0 = -4000/256;
TL0 = -4000%256;
P1 = (P1+1)%16;
rwe();
i++;
if(++t != 600)return;
t = 0;
z = (z + 1)%5;
} 展开
1个回答
展开全部
void rwe ()
{
temp = num[z][i*2];
io_595();
temp = num[z][i*2+1];
io_595();
i = i%16;
}
在这里,temp是16位的,num虽然定义是16位的,但实际有效数据是8位的,
改成一下试试:
void rwe ()
{
temp = num[z][i*2];
temp<<=8;
temp += num[z][i*2+1];
io_595();
i = i%16;
}
{
temp = num[z][i*2];
io_595();
temp = num[z][i*2+1];
io_595();
i = i%16;
}
在这里,temp是16位的,num虽然定义是16位的,但实际有效数据是8位的,
改成一下试试:
void rwe ()
{
temp = num[z][i*2];
temp<<=8;
temp += num[z][i*2+1];
io_595();
i = i%16;
}
更多追问追答
追问
首先,先谢谢你的建议。
但可能还有错误哦
我把它写成这样
void rwe()
{
te = num[z][i*2];
te = te << 8;
mp = num[z][i*2+1];
temp = te | mp;
io_595();
i = i%16;
}
效果跟你的建议一样
追答
现在是什么样的,能上图片不?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询