⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s0009302(lms019_80 example).c

📁 For 128x96dot 4wire serial LCM。8080模式。
💻 C
字号:
//-------------------------------------------------
// Shenzhen TOPWAY Technology Co.,Ltd.
// LCD Module:		  LMS019
// Display Size:      160x64
// Driver/Controller: SED1575
// Interface:         8080 mode
// by:                Kenny
// Date:			  2005-08-03
//-------------------------------------------------

#include <stdio.h>
#include <reg52.h>
#include <intrins.h>

#define uchar unsigned char // 0~255
#define uint unsigned int   // 0~65535

#define LCDBUS  	P1
//PS               = high;  // for parallel mode
sbit	_WR        = P3^7;
sbit	A0         = P3^6;
sbit	_RES       = P3^5; 
sbit	_CS1       = P3^4;
sbit	CS2        = P3^2;
sbit	C86        = P3^3;
sbit    _RD        = P3^1;

uchar   ContrastLevel;     // for contrast setting level 


//-----------------------------------
// dispaly data (160x64)
//-----------------------------------
uchar code Logo[]={
/*--  TOPWAY  LOGO 160x64  --*/
0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,
0xC0,0x40,0x40,0x00,0x80,0x40,0x40,0x40,0x80,0x00,0xC0,0x40,0x40,0x40,0x80,0x00,
0xC0,0x00,0x00,0x00,0xC0,0x00,0x00,0x80,0x40,0x80,0x00,0x00,0xC0,0x00,0x00,0x00,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,
0x1F,0xC0,0x80,0x00,0x8F,0xD0,0x10,0x90,0x4F,0x40,0x5F,0x82,0x02,0x82,0x41,0x40,
0x4F,0x90,0x0E,0x10,0x8F,0xC0,0x1F,0x02,0x02,0x82,0x5F,0x40,0x40,0x81,0x1E,0x81,
0x40,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x10,0x10,0x10,0x10,
0x00,0x1F,0x00,0x03,0x00,0x1F,0x00,0x09,0x12,0x12,0x12,0x0C,0x00,0x0F,0x14,0x12,
0x11,0x0F,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x09,0x12,0x12,0x12,0x0F,0x00,0x10,
0x18,0x14,0x12,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0xF0,0x00,0x00,0xE0,
0x90,0x90,0x90,0x00,0x00,0xE0,0x10,0x90,0x50,0xE0,0x00,0x20,0x40,0x80,0x40,0x20,
0x00,0xE0,0x90,0x90,0x90,0x00,0x00,0x80,0x40,0x20,0xF0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x80,0x00,0x00,0x40,0xD0,0x00,0x00,0x00,
0x40,0x80,0x00,0x80,0x40,0x00,0x80,0x40,0x40,0x40,0x80,0x00,0x00,0x10,0xF0,0x00,
0x00,0x00,0x80,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x03,
0x04,0x04,0x04,0x03,0x00,0x03,0x05,0x04,0x04,0x03,0x00,0x04,0x02,0x01,0x02,0x04,
0x00,0x03,0x04,0x04,0x04,0x03,0x00,0x01,0x01,0x01,0x07,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x01,0x01,0x01,0x00,0x00,0x00,0x04,0x07,0x04,0x00,0x00,
0x04,0x02,0x01,0x02,0x04,0x00,0x03,0x05,0x05,0x05,0x01,0x00,0x00,0x04,0x07,0x04,
0x00,0x00,0x04,0x05,0x05,0x05,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x80,
0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
0x00,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0x80,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x80,
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x21,0xBF,0x20,0x00,0x00,0xA1,0xB0,0xA8,0xA4,0x23,0x00,0x11,0xA0,
0xA4,0xA4,0x1B,0x00,0x8C,0x8A,0x89,0x3F,0x08,0x00,0x93,0xA2,0xA2,0xA2,0x9C,0x00,
0x9F,0xA4,0xA4,0xA4,0x98,0x00,0x00,0x80,0xBC,0x82,0x01,0x00,0x9B,0x24,0x24,0x24,
0x9B,0x00,0x13,0xA4,0xA4,0xA4,0x1F,0x00,0x1F,0xA8,0xA4,0xA2,0x9F,0x00,0x80,0x21,
0x3F,0x20,0x80,0x00,0xA1,0x30,0x28,0x24,0x23,0x00,0x91,0x20,0x24,0x24,0x9B,0x00,
0x8C,0x0A,0x09,0x3F,0x88,0x00,0x13,0xA2,0xA2,0xA2,0x1C,0x00,0x9F,0xA4,0xA4,0xA4,
0x18,0x00,0x00,0x80,0xBC,0x82,0x01,0x00,0x9B,0xA4,0xA4,0xA4,0x1B,0x00,0x13,0xA4,
0xA4,0xA4,0x1F,0x00,0x9F,0xA8,0xA4,0xA2,0x9F,0x00,0x80,0x21,0x3F,0x20,0x80,0x00,
0xA1,0x30,0x28,0x24,0xA3,0x00,0x91,0x20,0x24,0x24,0x9B,0x00,0x8C,0x0A,0x09,0x3F,
0x88,0x00,0x93,0x22,0x22,0x22,0x9C,0x00,0x9F,0xA4,0xA4,0xA4,0x98,0x00,0x00,0x00,
0xC0,0x80,0x3E,0x05,0x04,0x05,0x3E,0x00,0x3F,0x24,0x24,0x24,0x1B,0x00,0x1F,0x20,
0x20,0x20,0x11,0x00,0x3F,0x20,0x20,0x11,0x0E,0x00,0x3F,0x24,0x24,0x24,0x20,0x00,
0x3F,0x04,0x04,0x04,0x00,0x00,0x1F,0x20,0x24,0x24,0x1D,0x00,0x3F,0x04,0x04,0x04,
0x3F,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x10,0x20,0x20,0x1F,0x00,0x00,0x3F,0x04,
0x0A,0x11,0x20,0x00,0x3F,0x20,0x20,0x20,0x20,0x00,0x3F,0x01,0x06,0x01,0x3F,0x00,
0x3F,0x02,0x04,0x08,0x3F,0x00,0x1F,0x20,0x20,0x20,0x1F,0x00,0x3F,0x04,0x04,0x04,
0x03,0x00,0x1F,0x20,0x28,0x10,0x2F,0x00,0x3F,0x04,0x0C,0x14,0x23,0x00,0x13,0x24,
0x24,0x24,0x19,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x1F,0x00,
0x0F,0x10,0x20,0x10,0x0F,0x00,0x1F,0x20,0x1C,0x20,0x1F,0x00,0x31,0x0A,0x04,0x0A,
0x31,0x00,0x01,0x02,0x3C,0x02,0x01,0x00,0x30,0x28,0x24,0x22,0x21,0x00,0x80,0xC0};



//-----------------------------------
// Delay Routine
//-----------------------------------
void delayms(uint m)        // 12MHz Xtal, close to ms value
{
	uint j;
	uint i;
	
	for(i=0; i<m; i++)
	    for(j=0; j<109; j++)
	        _nop_();
}



//-----------------------------------
// IO Routine
//-----------------------------------
void SdCmd(uchar Command)   //send command
{
    _RD = 1;
    _WR = 1;
    A0 = 0;
    _CS1 = 0;
    LCDBUS = Command;
    _WR = 0;
    _nop_();
    _WR = 1;
    _CS1 = 1;    
}

void SdData(uchar DData)            //send data
{
    _RD = 1;
    _WR = 1;
    A0 = 1;
    _CS1 = 0;
    LCDBUS = DData;
    _WR = 0;
    _nop_();
    _WR = 1;
    _CS1 = 1;
}


//-----------------------------------
// clear screen
//-----------------------------------
void ClrScreen()	// fill 00h into DD RAM
{
    uchar i,j;
    for(i=0;i<8;i++)
        {
        LCDBUS=(0xb0|0x00);
    	SdCmd(0xb0 | i);	// select page 0~7
    	SdCmd(0x12);	    // start form column 24h
    	SdCmd(0x04);	    // (2byte command)
    	for(j=0;j<160;j++)
	    	{
	    	SdData(0x00);       // fill 00h into DDRAM
    		}
        }
}


//-----------------------------------
// Write a Screen
//-----------------------------------
void WriteScreen(uchar *DisplayData)	// DisplayData should be 164x64/8 = 1312byte
{
	uchar TempData;
	uchar i, j;
	for(i=0;i<8;i++)
	    {
    	SdCmd(0xb0 | i);	// select page 0~7
    	SdCmd(0x12);	    // start form column 24h
    	SdCmd(0x04);	    // (2byte command)
     	for(j=0;j<160;j++)
     		{
     		TempData=(*(DisplayData+(i*160)+j));
     		SdData(TempData);
 		    }
        }
}



//-----------------------------------
// Contrast control
//-----------------------------------
void LCD_Darker(void)
{
	if (ContrastLevel<0x3F)
    	{
        ContrastLevel++;
		}
    SdCmd(0x81);     		// E-Vol setting
	SdCmd(ContrastLevel);   // (2byte command)
}



void LCD_Lighter(void)
{
	if (ContrastLevel>0x00)
    	{
	     ContrastLevel--;
		}
    SdCmd(0x81);            // E-Vol setting
	SdCmd(ContrastLevel);   // (2byte command)
}



//-----------------------------------
// Init LCD module
//-----------------------------------
void initLCDM(void)
{
	_CS1	=1;     // not select
	CS2     =1;     // select
	A0	    =0;		// init for command
	_RD	    =1;     // not read
	_WR	    =1;     // not write
	C86     =0;     // 8080 mode
	LCDBUS=0xff;    // bus pull up
	_RES=1;         // reset pin
	_RES=0;
	delayms(1);
	_RES=1;
	delayms(1);
	
    ContrastLevel=0x22;   // Contrast Level
	
	SdCmd(0xab);          // turn on osc
	SdCmd(0xa2);	      // 1/9 bias
	SdCmd(0xa1);	      // ADC reverse	
	SdCmd(0xc8);          // COM Output=reverse
	SdCmd(0x40);          // Display start line =0
	SdCmd(0x2F);          // Power control=all on
	SdCmd(0x25);          // set Rab
	SdCmd(0x81);          // E-Vol setting
    SdCmd(ContrastLevel); // (2byte command)
    SdCmd(0xaf);          // display on
    ClrScreen();          // clear DDRAM
}



//-----------------------------------
// Main Program
//-----------------------------------
void main()
{
	SP=0x60;
	EA = 0;         // disable interrupts

   	initLCDM();
	ClrScreen();
	delayms(255);
    WriteScreen(Logo);

	while(1)
	{
 	}
}
//end of program

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -