本帖最后由 朱某mou 于 2020-10-19 17:29 编辑
#include"reg51.h"
#include"intrins.h"
//寄存器
sfr AUXR = 0x8E;
sfr P1M0 = 0x92;
sfr P1M1 = 0x91;
sfr P3M0 = 0xB2;
sfr P3M1 = 0xB1;
//IO口
sbit LA = P1^0;
sbit LB = P1^1;
sbit LC = P1^2;
sbit LD = P1^3;
sbit R1 = P1^4;
sbit R2 = P1^5;
sbit EN = P3^5;
sbit LAT = P3^6;
sbit CLK = P3^7;
unsigned char code zk[]={
0x08,0x00,0x08,0x00,0x0F,0xFC,0x14,0x00,0x24,0x00,0x47,0xF0,0x04,0x00,0x04,0x00,
0x07,0xF8,0x04,0x00,0x01,0x00,0x08,0x84,0x48,0x92,0x48,0x12,0x87,0xF0,0x00,0x00,/*"怎",0*/
0x01,0x00,0x01,0x00,0x02,0x00,0x02,0x00,0x04,0x40,0x08,0x40,0x10,0x80,0x20,0x80,
0x41,0x00,0x02,0x00,0x04,0x20,0x08,0x10,0x10,0x08,0x3F,0xFC,0x10,0x04,0x00,0x00,/*"么",1*/
0x20,0x00,0x27,0xFC,0x24,0x44,0x24,0x44,0xFC,0x44,0x27,0xFC,0x24,0x44,0x2C,0x44,
0x34,0x44,0xE7,0xFC,0x24,0x44,0x24,0x44,0x24,0x44,0x28,0x44,0xA8,0x54,0x50,0x08,/*"拥",2*/
0x02,0x00,0x02,0x00,0xFF,0xFE,0x04,0x00,0x04,0x00,0x0F,0xF0,0x08,0x10,0x18,0x10,
0x2F,0xF0,0x48,0x10,0x88,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10,0x08,0x50,0x08,0x20,/*"有",3*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"一",4*/
0x02,0x08,0x21,0x10,0x10,0x00,0x17,0xFC,0x00,0x80,0x03,0xF8,0xF2,0x08,0x13,0xF8,
0x12,0x08,0x13,0xF8,0x12,0x08,0x13,0xF8,0x12,0x08,0x28,0x00,0x47,0xFE,0x00,0x00,/*"道",5*/
0x01,0x00,0x07,0x84,0x78,0x04,0x08,0x88,0x44,0x90,0x25,0x22,0x20,0x02,0x04,0x04,
0x7F,0x88,0x0C,0x10,0x16,0x22,0x15,0x02,0x24,0x84,0x44,0x08,0x84,0x10,0x04,0x60,/*"彩",6*/
0x10,0x00,0x10,0x00,0x11,0xFC,0x7C,0x20,0x54,0x20,0x54,0x20,0x54,0x20,0x54,0x20,
0x7C,0x20,0x50,0x20,0x10,0x20,0x14,0x20,0x1E,0x20,0xE2,0x20,0x43,0xFE,0x00,0x00,/*"虹",7*/
};
//void Delay1ms() //@11.0592MHz
//{
// unsigned char i, j;
//
// _nop_();
// _nop_();
// _nop_();
// i = 11;
// j = 190;
// do
// {
// while (--j);
// } while (--i);
//}
void WriteIC(unsigned char DataR1,unsigned char DataR2)
{
unsigned char i;
for(i=0;i<8;i++)
{
R1 = DataR1&0x80;
R2 = DataR2&0x80;
CLK = 0;
CLK = 1;
DataR1 = DataR1 << 1;
DataR2 = DataR2 << 1;
}
}
void Dispaly()
{
unsigned char i,j;
for(i=0;i<16;i++)
{
EN = 0;
LAT = 0;
for(j=0;j<8;j++)
{
WriteIC(zk[j*32+i*2],0);
WriteIC(zk[j*32+i*2+1],0);
}
P1 = i;
LAT = 1;
EN = 1;
}
}
void main()
{
AUXR |= 0x80; //1T
P1M0 = 0xff; //推挽
P3M0 = 0xff;
P1M1 = 0;
P3M1 = 0;
while(1)
{
Dispaly();
}
}
过了很久再过来看这个问题,其实当时程序写的没有错
只是那个时候不明白这个接口上的电源和地有什么用,单片机就只接了信号线,电源和地没有和单片机接起来而是另外接的,现在还是用当时的代码,只是把接口上的电源和地,与单片机的电源和地接在一起了