单片机 自己写了了一个12864lcd(带字库)的图片显示程序,但就是显示不了,求大神帮忙看下 5
#include<reg52.h>#defineucharunsignedchar#defineuintunsignedintsbitrs=P2^0;sbitrw=P2^...
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit psb=P2^3;//串并方式选着
sbit RST= P2^4;
uint code tab[] ={1024个16进字数}
void delay1ms(uchar x)//延时
{
unsigned char i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void write_cmd(uchar cmd)//写指令
{
rs=0;
rw=0;
P0=cmd;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void write_data(uchar dat)//写数据
{
rs=1;
rw=0;
P0=dat;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void lcd_int()//lcd初始化
{
RST = 1;
psb = 1;
write_cmd(0x30); /*30---基本指令动作*/
delay1ms(5);
write_cmd(0x01); /*清屏,地址指针指向00H*/
delay1ms(5);
write_cmd(0x06); /*光标的移动方向*/
delay1ms(5);
write_cmd(0x0c);/*显示开及光标设置*/
}
void display_bmp(uchar code *address)
{
uchar i,j,k;
for(j=0;j<32;j++)
{
for(i=0;i<8;i++)
{
write_cmd(0x34);
write_cmd(0x80+j);//先送垂直地址
write_cmd(0x80+i);
write_cmd(0x30);
if(i==0)
{
write_cmd(0x80);
}
else
{
write_cmd(0x88);
}
for(k=0;k<16;k++)
{
write_data(*address++);
}
}
}
}
void clrram(void)
{
write_cmd(0x01);
write_cmd(0x34);
write_cmd(0x30);
}
main()
{
lcd_int();
while(1)
{
void clrram();
delay1ms(50);
display_bmp(tab);
delay1ms(5000);
}
} 展开
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit psb=P2^3;//串并方式选着
sbit RST= P2^4;
uint code tab[] ={1024个16进字数}
void delay1ms(uchar x)//延时
{
unsigned char i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void write_cmd(uchar cmd)//写指令
{
rs=0;
rw=0;
P0=cmd;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void write_data(uchar dat)//写数据
{
rs=1;
rw=0;
P0=dat;
delay1ms(5);
en=1;
delay1ms(5);
en=0;
}
void lcd_int()//lcd初始化
{
RST = 1;
psb = 1;
write_cmd(0x30); /*30---基本指令动作*/
delay1ms(5);
write_cmd(0x01); /*清屏,地址指针指向00H*/
delay1ms(5);
write_cmd(0x06); /*光标的移动方向*/
delay1ms(5);
write_cmd(0x0c);/*显示开及光标设置*/
}
void display_bmp(uchar code *address)
{
uchar i,j,k;
for(j=0;j<32;j++)
{
for(i=0;i<8;i++)
{
write_cmd(0x34);
write_cmd(0x80+j);//先送垂直地址
write_cmd(0x80+i);
write_cmd(0x30);
if(i==0)
{
write_cmd(0x80);
}
else
{
write_cmd(0x88);
}
for(k=0;k<16;k++)
{
write_data(*address++);
}
}
}
}
void clrram(void)
{
write_cmd(0x01);
write_cmd(0x34);
write_cmd(0x30);
}
main()
{
lcd_int();
while(1)
{
void clrram();
delay1ms(50);
display_bmp(tab);
delay1ms(5000);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询