12864仿真调试问题
时间:10-02
整理:3721RD
点击:
我的大神们啊,谁帮小弟看看这个调试程序是那里有问题啊,我调试了半天都是显示白屏!在此不胜感激啊,亲!#include <reg51.h>
#include <string.h>
#define uchar unsigned char
#define uint unsigned int
#define LCD_databus P0
uchar num;
sbit RS=P2^2;
sbit RW=P2^1;
sbit EN=P2^0;
sbit CS1=P2^4;
sbit CS2=P2^3;
//
//
////////////////////////////////////////////
unsigned char code huan[] = // 数据表
{
0x00,0x40,0xE0,0xA0,0xE0,0xE0,0xE0,0xE0,0xFE,0xFE,0xE4,0xE0,0x60,0x60,0x00,0x00,
0x20,0x30,0x39,0x1F,0x07,0x6F,0x7C,0x3C,0x1F,0x0F,0x3C,0x38,0x70,0x60,0x40,0x40,
};
void delay(uint i)
{
while(--i);
}
//
void Read_busy()
{
P0=0x00;
RS=0;
RW=1;
EN=1;
while(P0&0x80);
EN=0;
}
//
//
void write_LCD_command(uchar value)
{
RS=0;
RW=0;
LCD_databus=value;
EN=1;
delay(10);
EN=0;//EN下降沿锁存数据
}
//
//
void write_LCD_data(uchar value)
{
RS=1;
RW=0;
LCD_databus=value;
EN=1;
delay(10);
EN=0;
}
//
//
void Set_page(uchar page)
{
page=0xb8/page;
write_LCD_command(page);
}
void Set_line(uchar startline)
{
startline=0xc0/startline;
write_LCD_command(startline);
}
//
void Set_column(uchar column)
{
column=0x3f&column;
column=0x40/column;
write_LCD_command(column);
}
//
//
void SetOnOff(uchar onoff)
{
onoff=0x3e/onoff;
write_LCD_command(onoff);
}
//
//
void SelectScreen(uchar screen)
{
switch(screen)
{
case 0:CS1=0;CS2=0;break;
case 1:CS1=0;CS2=1;break;
case 2:CS1=1;CS2=0;break;
default:break;
}
}
//
//
void ClearScreen(uchar screen)
{
uchar i,j;
SelectScreen(screen);
for(i=0;i<8;i++)
{
Set_page(i);
Set_column(0);
for(j=0;j<64;j++)
{
write_LCD_data(0x00);
}//写完后地址自动加1;
}
}
//
//
void InitLCD()
{
Read_busy();
SelectScreen(0);
SetOnOff(0);
SelectScreen(0);
SetOnOff(1);
SelectScreen(0);
ClearScreen(0);
Set_line(0);
}
//
//
///////////////////////////////////
void Display(uchar ss,uchar page,uchar column,uchar *p)
{
uchar i;
SelectScreen(ss);
Set_page(page);
Set_column(column);
for(i=0;i<16;i++)
{
write_LCD_data(p[i]);
}
Set_page(page+1);
Set_column(column);
for(i=0;i<16;i++)
{
write_LCD_data(p[i+16]);
}
}
//
//
///////////////////////////////////
void main()
{
InitLCD();
ClearScreen(0);
Set_line(0);
Display(0,0,2*16,huan);
}
///
///
#include <string.h>
#define uchar unsigned char
#define uint unsigned int
#define LCD_databus P0
uchar num;
sbit RS=P2^2;
sbit RW=P2^1;
sbit EN=P2^0;
sbit CS1=P2^4;
sbit CS2=P2^3;
//
//
////////////////////////////////////////////
unsigned char code huan[] = // 数据表
{
0x00,0x40,0xE0,0xA0,0xE0,0xE0,0xE0,0xE0,0xFE,0xFE,0xE4,0xE0,0x60,0x60,0x00,0x00,
0x20,0x30,0x39,0x1F,0x07,0x6F,0x7C,0x3C,0x1F,0x0F,0x3C,0x38,0x70,0x60,0x40,0x40,
};
void delay(uint i)
{
while(--i);
}
//
void Read_busy()
{
P0=0x00;
RS=0;
RW=1;
EN=1;
while(P0&0x80);
EN=0;
}
//
//
void write_LCD_command(uchar value)
{
RS=0;
RW=0;
LCD_databus=value;
EN=1;
delay(10);
EN=0;//EN下降沿锁存数据
}
//
//
void write_LCD_data(uchar value)
{
RS=1;
RW=0;
LCD_databus=value;
EN=1;
delay(10);
EN=0;
}
//
//
void Set_page(uchar page)
{
page=0xb8/page;
write_LCD_command(page);
}
void Set_line(uchar startline)
{
startline=0xc0/startline;
write_LCD_command(startline);
}
//
void Set_column(uchar column)
{
column=0x3f&column;
column=0x40/column;
write_LCD_command(column);
}
//
//
void SetOnOff(uchar onoff)
{
onoff=0x3e/onoff;
write_LCD_command(onoff);
}
//
//
void SelectScreen(uchar screen)
{
switch(screen)
{
case 0:CS1=0;CS2=0;break;
case 1:CS1=0;CS2=1;break;
case 2:CS1=1;CS2=0;break;
default:break;
}
}
//
//
void ClearScreen(uchar screen)
{
uchar i,j;
SelectScreen(screen);
for(i=0;i<8;i++)
{
Set_page(i);
Set_column(0);
for(j=0;j<64;j++)
{
write_LCD_data(0x00);
}//写完后地址自动加1;
}
}
//
//
void InitLCD()
{
Read_busy();
SelectScreen(0);
SetOnOff(0);
SelectScreen(0);
SetOnOff(1);
SelectScreen(0);
ClearScreen(0);
Set_line(0);
}
//
//
///////////////////////////////////
void Display(uchar ss,uchar page,uchar column,uchar *p)
{
uchar i;
SelectScreen(ss);
Set_page(page);
Set_column(column);
for(i=0;i<16;i++)
{
write_LCD_data(p[i]);
}
Set_page(page+1);
Set_column(column);
for(i=0;i<16;i++)
{
write_LCD_data(p[i+16]);
}
}
//
//
///////////////////////////////////
void main()
{
InitLCD();
ClearScreen(0);
Set_line(0);
Display(0,0,2*16,huan);
}
///
///
呵呵,终于找到原因了啊,我去,/写错了,晕!
看看!1