给您一个我的程序看一下:
可以显示图片,可以显示字符,唯独不可以利用输入坐标参数控制在LCD上的显示位置。
void initLCDM(void)
{
//_RES = 1; // reset pin
//_RES = 0;
delayms(5);
//_RES = 1;
delayms(10);
SdCmd(0x40); //System set (8 byte parameter)
SdData(0x30); // IV=1(no line comp),ws=0(single drv),M2=0(8bit char height),M0=0(int CGROM), D4=1(by default)
SdData(0x87); // MOD=1 two frame AC drv, HorChar Size=8
SdData(0x07); // VerChar Size=8
SdData(0x28); // (320/8=40) char per line
SdData(0x47); // 23+blanking (frame freq = 66Hz (clk ratio=1/4 @ 10MHz)
SdData(0xEF); // (240-1=239) line per screen
SdData(0x28); // Virtual screen width LSB
SdData(0x00); // Virtual screen width MSB
SdCmd(0x59); // Display ON/OFF(1 byte parameter)
SdData(0x04); // SAD1=on, cursor=off
SdCmd(0x44); //Scroll (10 byte parmeter)
SdData(0x00); // SAD1 start ADD LSB
SdData(0x00); // SAD1 start ADD MSB
SdData(0xEF); // SAD1 block size(no.of line-1)
SdData(0x00); // SAD2 start ADD LSB
SdData(0x00); // SAD2 start ADD MSB
SdData(0xEF); // SAD2 block size(no.of line-1)
SdData(0x00); // SAD3 start ADD LSB
SdData(0x00); // SAD3 start ADD MSB
SdData(0x00); // SAD4 start ADD LSB
SdData(0x00); // SAD4 start ADD MSB
SdCmd(0x5D); //CSRFORM (2 byte parmeter)
SdData(0x07); // cursor width = 8
SdData(0x17); // CM=1, for graphic mode, cursor height = 8
SdCmd(0x4C); // CSRDIR (0 byte parmeter) to the right side
SdCmd(0x5B); // OVLAY (1 byte parmeter)
SdData(0x05); // 0v=0(2layer),DM1=0(blk3 for text),DM0=1(blk1 for graphic),layers combine=01(XOR)
/* SdCmd(0x5C); // CGRAMADR (2 byte parmeter)
SdData(0x00);
SdData(0x00);
*/
SdCmd(0x5A); // HDOT SCR (1 byte parmeter)
SdData(0x00); // no scroll
SdCmd(0x60); // GRAYSCALE (1 byte parmeter)
SdData(0x00); // 1bpp
}
、、
//-----------------------------------
//描点函数
//-----------------------------------
void Draw_Dot(uint x,uint y)
{
uchar dotdata,m ;
uint addr;
addr = y * 0x30 + x/8 ;
m = x % 8;
dotdata = 0x80;
dotdata = dotdata >> m;
SdCmd(0x46);
SdData(addr);
SdData(addr >> 8);
SdCmd(0x43);
m = RdData() | dotdata;
SdCmd(0x46);
SdData(addr);
SdData(addr >> 8);
SdCmd(0x42);
SdData(m);
}
void main()
{
int i;
uint x,y;
uchar test_asc[] = "1234567abcdef";
DDRC |= 0XFF;
//SP=0x60;
//EA = 0; // disable interrupts
//_RES = 1; // init all signal
DDRG |= 0x04;
PORTG |= 0X04;//_CS = 1;
DDRG |= 0x02;
PORTG |= 0X02;//_RD = 1;
//_WR = 1; wr pg0
DDRG |= 0x01;
PORTG |= 0X01;
// A0 = 0;
DDRG |= 0x08;
PORTG |= 0X08;//PORTG &= ~0X08;
PORTC = 0xff;//LCDBUS = 0xff; // pull up data bus
//PORTC = 0x55;
initLCDM();
Clear_LCD();
DDRA |= 0x04;
PORTA |= 0X04;
while(1)
{
WriteGraphicScreen(Graphic**); delayms(1000); //可以正确显示的整屏图片
WritePatternScreen(Pat_AllOn); delayms(1000);
WritePatternScreen(Pat_AllOff); delayms(1000);
Draw_Dot(0,0); //可以正确显示
Draw_Dot(3,3); //显示不出来
for(y=0;y<240;y++)
Draw_Dot(50,y); //没有显示出直线而是一些间隔显示的点
delayms(2000);}
}
}
虽然这样问问题比较烦,但确实着急,请高手指点迷津!
|