用LCD1602的CGRAM顯示自定義的漢字 不知道哪里出錯 就是不顯示 求大神解答
#include<reg52.h>
sbit CE = P2^7;
sbit RW = P2^5;
sbit RS = P2^6;
unsigned char table[]=
{
0x1F,0x11,0x11,0x1F,0x11,0x11,0x1F,0x00,//日
0x0F,0x09,0x0F,0x09,0x0F,0x09,0x09,0x12,//月
0x04,0x0F,0x12,0x0F,0x0A,0x1F,0x02,0x02,//年
};
void Read_Busy()
{
unsigned char busy;
P0 = 0xff;
RS = 0;
RW = 1;
do{
CE = 1;
busy = P0;
CE = 0;
}while(busy>7);
}
void Write_Cmd(unsigned char cmd)
{
Read_Busy();
RS = 0;
RW = 0;
P0 = cmd;
CE = 1;
CE = 0;
}
void Write_Data(unsigned char dat)
{
Read_Busy();
RS = 1;
RW = 0;
P0 = dat;
CE = 1;
CE = 0;
}
void main()
{
int i;
Write_Cmd(0x01);//數據指針清零 所有顯示清零
Write_Cmd(0x38);//設置顯示
Write_Cmd(0x0f);//開顯示 光標閃爍
Write_Cmd(0x06);//設置指針 光標 不移屏
Write_Cmd(0x41); //寫入CGROM
for(i=0;i<24;i++)
{
Write_Data(table[i]);
}
Write_Cmd(0x80);//設置地址指針
Write_Data(0x00);
Write_Data(0x01);
Write_Data(0x02);
while(1);
}
|