|
发表于 2009-7-22 02:21:55
|
显示全部楼层
我碰到一个见鬼的问题,请大侠们看下我的程序:
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
extern uchar code zimo[];
#define LCom 0x1f00 //左区指令
#define LData 0x1f01 //左区数据
#define RCom 0x3f00 //右区指令
#define RData 0x3f01 //右区数据
uchar xdata XBYTE[65535];
//***********************************************
//初始化函数
//***********************************************
void LCD_Init(void)
{
XBYTE[LCom] = 0XE2;
XBYTE[RCom] = 0XE2; //复位
XBYTE[LCom] = 0xAE;
XBYTE[RCom] = 0XAE; //POWER SAVE
XBYTE[LCom] = 0XA4;
XBYTE[RCom] = 0XA4; //动态驱动
XBYTE[LCom] = 0XA9;
XBYTE[RCom] = 0XA9; //1/32占空比
XBYTE[LCom] = 0XA0;
XBYTE[RCom] = 0XA0; //时钟线输出
XBYTE[LCom] = 0XEE;
XBYTE[RCom] = 0XEE; //写模式
XBYTE[LCom] = 0X00;
XBYTE[LCom] = 0XC0;
XBYTE[RCom] = 0X00;
XBYTE[RCom] = 0XC0;
XBYTE[LCom] = 0XAF;
XBYTE[RCom] = 0XAF;
}
void PutDataL(uchar ch) //发送左区数据
{
XBYTE[LData] = ch;
}
void PutDataR(uchar ch) //发送右区数据
{
XBYTE[RData] = ch;
}
void PutComL(uchar ch) //发送左区指令
{
XBYTE[LCom] = ch;
}
void PutComR(uchar ch) //发送右区指令
{
XBYTE[RCom] = ch;
}
void SetPage(uchar page1,uchar page2) //设置显示页
{
XBYTE[LCom] = (0xB8|page2);
XBYTE[RCom] = (0xB8|page1);
}
void SetAddress(uchar address0, uchar address1) //设置开始列
{
XBYTE[LCom] = (address1);
XBYTE[RCom] = (address0);
}
void clrscr(void)
{
uchar i;
uchar page;
for (page=0;page<4;page++)
{
SetPage(page,page);
SetAddress(0,0);
for (i=0;i<61;i++){PutDataL(0);PutDataR(0);}
}
}
void main(void)
{
uchar i,ch;
ch = 0xff;
LCD_Init();
clrscr();
SetPage(2,2);
SetAddress(0,0);
for(i=0;i<16;i++) PutDataR(zimo);
SetPage(3,3);
SetAddress(0,0);
for(i=0;i<16;i++) PutDataR(zimo[i+16]);
while(1);
}
uchar code zimo[]= {0,4,116,85,86,84,116,4,0,254,2,34,90,134,0,0,0,9,9,41,61,7,5,4,0,63,4,8,8,7,0,0};
这是一段测试12232的程序,本来是想在page2、3页的右边0列开始显示一个“郭”,
结果通电复位后在page2、3、0、1的右边从0列开始到61列全黑。
将程序的第二个for改为:for(i=16;i<32;i++) PutDataR(zimo);时,显示正常,这到底是怎么回事?请高手指教!!谢谢! |
|