|
我想在第六列显示一条竖线,但它在第103列显示,请高人给看看问题出在哪,程序如下:
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define LcdDataPort P2
sbit _WR=P1^1;
sbit RS=P1^2;
sbit _RES=P1^3;
sbit _CS1=P1^4;
void Delay(uint Delx) //延时
{
uint i=0;
while(i
i++;
}
void LcdCommand(uchar Com) //写指令
{
RS=0;
LcdDataPort=Com;
_nop_();_nop_();_nop_();
_WR=0;
_nop_();_nop_();_nop_();
_WR=1;
}
void LcdDataWrite(uchar Data) //写数据
{
RS=1;
LcdDataPort=Data;
_nop_();_nop_();_nop_();
_WR=0;
_nop_();_nop_();_nop_();
_WR=1;
}
void Initialize() //初始化
{
_CS1=0;
_RES=0;
Delay(1000);
_RES=1;
LcdCommand(0xa0);
LcdCommand(0xc8);
LcdCommand(0xa2);
LcdCommand(0x2f);
LcdCommand(0x81);
LcdCommand(0x29);
LcdCommand(0x40);
LcdCommand(0xaf);
}
void SetPage(uchar Page) //页位置
{
Page=Page&0x0f;
Page=Page|0xb0;
LcdCommand(Page);
}
void SetColumn(uchar Column) //列位置
{
uchar temp;
temp=Column;
Column=Column&0x0f;
Column=Column|0x00;
LcdCommand(Column);
temp=temp>>4;
Column=Column&0x0f;
Column=Column|0x10;
LcdCommand(Column);
}
void ClearScr() //清屏
{
uchar i,j;
for(i=0;i<8;i++)
{
SetColumn(0);
SetPage(i);
for(j=0;j<128;j++)
LcdDataWrite(0x00);
}
}
void Display(uchar Page,uchar Column) //显示
{
uchar i;
for(i=0;i<8;i++)
{
SetPage(Page+i);
SetColumn(Column);
LcdDataWrite(0xff);
}
}
void main() //主函数
{
Initialize();
Delay(1000);
ClearScr();
Display(0,6);
while(1)
{};
}
|
|