微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 51单片机-240128液晶程序与调试

51单片机-240128液晶程序与调试

时间:11-13 来源:互联网 点击:

-----------------------

uchar lcd_regread(uchar regname) small

{

uchar reg_rddata;

lcd_regwr(regname);

lcd_data = 0xff;

lcd_cs1 =0;

lcd_wr = 1;

lcd_rs = 0;

lcd_rd = 0;

;

reg_rddata = lcd_data;

lcd_rd = 1;

lcd_rs = 1;

lcd_cs1 =1;

return(reg_rddata);

}

//=============================================

void delay(int k)

{

int i;

for(i=0;i

;

}

void delay1 (int ms)

{

int i,j;

for(i=0;i

for(j=0;j<123;j++)

;

}

//=============================================

void lcd_reset(void) small

{

delay1(120);

lcd_control = 0xff; // lcd_rs/wr/rd/cs1/cs2 normal - skeep high.

}

//---------------------------------------------

void lcd_initial(void) small

{

lcd_regwrite(0x00,0xc9); // lcd control register(lcr)

lcd_regwrite(0x01,0xf2); // misc.register(mir)

lcd_regwrite(0x02,0x10); // advance power setup register(apsr)

lcd_regwrite(0x03,0x80); // advance display setup regiser(adsr)

lcd_regwrite(0x10,0x6b); // cursor control register(ccr)

lcd_regwrite(0x11,0x00); // distance of word or lines register(dwlr)

lcd_regwrite(0x12,0x91); // memory access mode register(awrr)

lcd_regwrite(0x21,0x1d); // display window right register(dwrr)

lcd_regwrite(0x31,0x7f); // display window bottom register(dwbr)

lcd_regwrite(0x41,0x00); // display window left register(dwlr)

lcd_regwrite(0x51,0x00); // display window top register(dwtr)

lcd_regwrite(0x20,0x1d); // active window right register(awrr)

lcd_regwrite(0x30,0x7f); // active window bottom register(awbr)

lcd_regwrite(0x40,0x00); // active window left register(awlr)

lcd_regwrite(0x50,0x00); // active window top register(awtr)

lcd_regwrite(0x60,0x00); // cursor position x register(cpxr)

lcd_regwrite(0x61,0x00); // begin segment position register(bgsg)

lcd_regwrite(0x70,0x00); // cursor position y register(cpyr)

lcd_regwrite(0x71,0x00); // shift action range,begin commom register(bgcm)

lcd_regwrite(0x72,0x7f); // shift action range,end commom register(edcm)

lcd_regwrite(0x80,0xaa); // blink time register(btr)

lcd_regwrite(0x81,0x00); // frame rate polarity change at common_fa register(fdca)

lcd_regwrite(0x91,0x00); // frame rate polarity change at common_fb register(fdcb)

lcd_regwrite(0x90,0x0f); // shift clock control register(sccr)

lcd_regwrite(0xa0,0x11); // interrupt setup & status register(frcb)

lcd_regwrite(0xa1,0x00); // key scan control register(kscr)

lcd_regwrite(0xa2,0x00); // key scan data register(ksdr)

lcd_regwrite(0xa3,0x00); // key scan data expand register(kser)

lcd_regwrite(0xb0,0x1d); // interrupt column setup register(intx)

lcd_regwrite(0xb1,0x7f); // interrupt row setup register(inty)

lcd_regwrite(0xc0,0x00); // touch panel control register(tpcr)

lcd_regwrite(0xc1,0x0a); // adc status register(adcs)

lcd_regwrite(0xc8,0x80); // touch panel segment high byte data register(tpxr)

lcd_regwrite(0xc9,0x80); // touch panel common high byte data register(tpyr)

lcd_regwrite(0xca,0x00); // touch panel segment/common low byte data register(tpzr)

lcd_regwrite(0xd0,0x80); // lcd contrast control register (lccr)

lcd_regwrite(0xe0,0x00); // pattern data register(pdr)

lcd_regwrite(0xf0,0xa0); // FONT control register(fcr)

lcd_regwrite(0xf1,0x0f); // FONT size control register

}

//---------------------------------------------

void lcd_clear(void) small

{

uchar reg_rddata;

lcd_regwrite(0xe0,0x00);

reg_rddata = lcd_regread(0xf0);

reg_rddata |= 0x08;

lcd_regwrite(0xf0,reg_rddata);

}

//---------------------------------------------

void lcd_photo(uchar code *pho) small

{

uchar i,j;

uchar code *pp;

gotoxy(0,0);

pp=pho;

for(j=0;j<128;j++)

{

for(i=0;i<30;i++)

{

lcd_datawrite(*pp);

++pp;

}

}

}

//---------------------------------------------

void lcd_lattice(uchar data1,uchar data2) small

{

uch

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top