12864 LCD graphics display program example

Publisher:jiaohe1Latest update time:2016-11-03 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include "pic.h" 
#define RS RC0 
#define RW RC1 
#define E RC2 
#define PSB RC3 
#define RST RC4 
//PORTD=DATA; 
unsigned char COUNT3,COUNT2,COUNT1,COUNT,LCD_X,LCD_Y,LCD_DATA1,LCD_DATA2,LCD_DATA,F3,R1,F0;
const unsigned char TU_TAB1[]={ 
// 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x18,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xDC,0x00,0x01, 
0x80,0x00,0x1F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xBC,0x00,0x01, 
0x80,0x00,0x30,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0xB8,0x00,0x01, 
0x80,0x00,0x30,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0x78,0x00,0x01, 
0x80,0x00,0x19,0xFF,0xFE,0xC0,0x00,0x00,0x00,0x00,0x02,0xFF,0xFF,0x70,0x00,0x01, 
0x80,0x00,0x18,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02,0xFF,0xFE,0xF0,0x00,0x01, 
0x80,0x00,0x0C,0x01,0xFF,0x60,0x00,0x00,0x00,0x00,0x05,0xFF,0xFE,0xE0,0x00,0x01, 
0x80,0x00,0x0C,0x7F,0xD0,0x20,0x00,0x00,0x00,0x00,0x05,0xFF,0xFD,0xE0,0x00,0x01, 
0x80,0x00,0x06,0x00,0x0F,0xB0,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFD,0xC0,0x00,0x01, 
0x80,0x00,0x06,0x03,0xFC,0x10,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFB,0xC0,0x00,0x01, 
0x80,0x00,0x03,0x1F,0x00,0x18,0x00,0x00,0x00,0x00,0x17,0xFF,0xFB,0x80,0x00,0x01, 
0x80,0x00,0x03,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x80,0x00,0x01, 
0x80,0x00,0x01,0x80,0x00,0x0C,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x00,0x00,0x01, 
0x80,0x00,0x01,0x80,0x00,0x04,0x00,0x00,0x00,0x00,0x09,0xFF,0xEF,0x00,0x00,0x01, 
0x80,0x00,0x00,0xC0,0x00,0xF6,0x00,0x00,0x00,0x00,0x06,0x7F,0xEE,0x00,0x00,0x01, 
0x80,0x00,0x00,0xC0,0x03,0xC2,0x00,0x00,0x00,0x00,0x01,0x9F,0xDE,0x00,0x00,0x01, 
0x80,0x00,0x00,0x60,0x00,0x3B,0x00,0x00,0x00,0x00,0x00,0x67,0xDF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x60,0x00,0xE3,0x00,0x00,0x00,0x00,0x00,0x19,0xBF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x30,0x03,0x8E,0x00,0x00,0x00,0x00,0x00,0x06,0x3F,0x00,0x00,0x01, 
0x80,0x00,0x00,0x30,0x06,0x3C,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x18,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x18,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x0F,0x7F,0x80,0x00,0x01, 
0x80,0x00,0x00,0x0C,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1F,0xC0,0x00,0x01, 
0x80,0x00,0x00,0x0C,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x07,0xE0,0x00,0x01, 
0x80,0x00,0x00,0x06,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x1F,0xE0,0x00,0x01, 
0x80,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0xC0,0x00,0x01, 
0x80,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0xFF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFC,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x05,0x40,0x88,0x04,0x01,0x08,0x00,0x00,0x0A,0x81,0x10,0x04,0x00,0x20,0x01, 
0x80,0x79,0x21,0x08,0x02,0x21,0x49,0x00,0x00,0xF2,0x42,0x10,0x04,0x47,0x10,0x01, 
0x80,0x09,0x07,0xDF,0x7F,0xF7,0xAA,0x00,0x00,0x12,0x0F,0xBE,0x7F,0xE5,0xFE,0x01, 
0x80,0x7F,0xF4,0x51,0x08,0x81,0x2C,0x00,0x00,0xFF,0xE8,0xA2,0x44,0x47,0x00,0x01, 
0x80,0x09,0x04,0x61,0x08,0x81,0x7F,0x00,0x00,0x12,0x08,0xC2,0x7F,0xC5,0x4A,0x01, 
0x80,0x0B,0x24,0x51,0x08,0x83,0x81,0x00,0x00,0x16,0x48,0xA2,0x44,0x45,0x6A,0x01, 
0x80,0x1D,0x47,0xC9,0x05,0x05,0x01,0x00,0x00,0x3A,0x8F,0x92,0x44,0x47,0x52,0x01, 
0x80,0x68,0x84,0x49,0x05,0x05,0x7F,0x00,0x00,0xD1,0x08,0x92,0x7F,0xC5,0x6A,0x01, 
0x80,0x09,0x94,0x41,0x02,0x01,0x01,0x00,0x00,0x13,0x28,0x82,0x44,0x05,0x4A,0x01, 
0x80,0x0E,0x57,0xC1,0x0D,0x81,0x01,0x00,0x00,0x1C,0xAF,0x82,0x04,0x29,0x42,0x01, 
0x80,0x38,0x34,0x4E,0x70,0x71,0x7F,0x00,0x00,0x70,0x68,0x9C,0x03,0xEB,0x7E,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF 
}; 

//*************delay_ms******************************** 
void delay_10us(unsigned char x) 

while(x--); 

void delay_ms(unsigned char cnt) 

unsigned char i; 
do { 
i = 4; 
do { 
delay_10us(39); 
} while(--i); 
} while(--cnt); 


//***********检查是否LCD忙碌的子程序********************** 
void check_busy(void) 

TRISD=0xff;//在此处设为输入。 
PORTD=0xff; 
RS=0; 
RW=1; 
while (1) 

NOP();NOP();NOP(); 
E =1; 
NOP();NOP();NOP(); 
if (RD7==0) break; 
NOP();NOP();NOP(); 
E =0; 

E =0; 
TRISD=0X00;//还原为输出。 
RC7=!RC7; 
//delay_ms(50); 

//**********数据写命令*************************** 
void send_com(unsigned char command ) 

check_busy(); 
RS=0; 
RW=0; 
PORTD=command; 
E =1; 
NOP(); 
NOP(); 
E =0; 

//**********LCD初始化时的送命令****************** 
void send_com_init(unsigned char command_init ) 

RS=0; 
RW=0; 
PORTD=command_init; 
E =1; 
NOP(); 
NOP(); 
E =0; 

//**********写数据*************************** 
void send_data(unsigned char data ) 

check_busy(); 
RS=1; 
RW=0; 
PORTD=data; 
E =1; 
NOP(); 
NOP(); 
E =0; 

//***********读数据**************************** 
unsigned char read_data(void) 

unsigned char read_data; 
check_busy(); 
TRISD=0XFF; 
RS=1; 
RW=1; 
E =1; 
NOP(); 
read_data=PORTD; 
E =0; 
TRISD=0x00;//还原为输出。 
return (read_data); 

//***********Clear screen******************************** 
void clear_LCD(void) 

send_com(0x01); 
send_com(0x34); 
send_com(0x30); 

//**********LCD initialization**************************** 
void initial_LCD(void) 

PSB=1; 
RST=0;//Reset. 
NOP(); 
NOP(); 
RST=1; 
NOP(); 
delay_10us(10); 
send_com_init(0x30);//30H--basic instruction operation 
delay_10us(4); 
send_com_init(0x0c);//Turn on display, turn off cursor, no blinking. 
delay_10us(10); 
send_com_init(0x01);//Clear display 
delay_ms(10); 
send_com_init(0x06);//Specify the direction of cursor movement when writing or reading data, and add 1 to the address counter (AC) of DDRAM.


//**********Write preparation****************************** 
void WR_ZB(void) 

send_com(0x34); 
send_com(LCD_Y); 
send_com(LCD_X); 
send_com(0x30); 

//*********Get data and send to display********************************** 
void QUSHU(const unsigned char *shu) 

for (;COUNT!=0;COUNT--) 

send_data(*shu++); 
delay_ms(80); 


//*********Flash****************************** 
void flash(void) 

send_com(0x08);//Turn off display 
delay_ms(250); 
send_com(0x0c);//Turn on display, turn off cursor, no blinking. 
delay_ms(250); 
send_com(0x08);//Turn off display 
delay_ms(250); 
send_com(0x0c);//Turn on display, turn off cursor, no blinking. 
delay_ms(250); 
send_com(0x08);//turn off display 
delay_ms(250); 

//**********Display graphics subroutine************************ 
void PHO_DISP(const unsigned char *s) 

COUNT3=0X02; 
LCD_X=0X80; 
for (;COUNT3!=0;COUNT3--) 

LCD_Y=0X80; 
COUNT2=0X20;//32 
for (;COUNT2!=0;COUNT2--) 

COUNT1=0X10;//16 
WR_ZB(); 
for (;COUNT1!=0;COUNT1--) 

send_data(*s++); 


LCD_Y+=1; 

LCD_X=0X88; 

send_com(0x36); 
send_com(0x30); 

//******************Display dot matrix subroutine************ 
void LAT_DISP(void) 

COUNT3=0X02; 
LCD_X=0X80; 
for (;COUNT3!=0;COUNT--) 

LCD_Y=0X80; 
F0=0; 
COUNT2=0X20; 
for (;COUNT2!=0;COUNT--) 

COUNT1=0X10; 
WR_ZB(); 
if (F0!=0) 

LCD_DATA=LCD_DATA2; 

else LCD_DATA=LCD_DATA1; 
for (;COUNT1!=0;COUNT1--) 

send_data(LCD_DATA); 

LCD_Y+=1; 
F0=!F0; 

LCD_X=0X88; 


send_com(0x36); 
send_com(0x30); 


void main(void) 

TRISC=0X00; 
TRISD=0X00; 
PORTD=0X00; 
PORTC=0X00; 
initial_LCD(); 
while (1) 

clear_LCD(); 
PHO_DISP(TU_TAB1);//显示图形 
while (1); 

}
Reference address:12864 LCD graphics display program example

Previous article:Four-digit digital tube dynamic display PROTEUS simulation based on PIC16F877
Next article:Simple Application of PIC Microcontroller ADC

Recommended ReadingLatest update time:2024-11-16 16:44

Controller design suitable for LCD display
With the continuous development of display technology, true color LCD screens have gradually occupied an important position in embedded display systems with their advantages such as high resolution, high contrast and high definition. At present, there are two main ways to implement LCD display control technology based
[Microcontroller]
Controller design suitable for LCD display
12864 LCD menu design
Why is the menu called a menu? I can't find the reason anymore. I'm afraid I'll be scolded if I throw out a bunch of old papers and list a bunch of opinions on this issue. Whether you admit it or not, the concept of menu has penetrated into every aspect of our lives with the popularization of computers. Many things ca
[Microcontroller]
In-depth understanding of ARM architecture (S3C6410) --- LCD display picture
The S3C6410 display controller contains logic circuits that transfer data from the local bus of the post processor or system memory video buffer data to the external LCD driver interface circuit. The S3C6410 contains 4 interfaces: traditional RGB interface, I80 interface, standard TV encoding interface NTSC/PAL, IT-R B
[Microcontroller]
In-depth understanding of ARM architecture (S3C6410) --- LCD display picture
LCD Experiment Study Notes (9): UART
The s3c2440 contains three universal asynchronous receivers and transmitters that can work in interrupt mode or DMA mode. Each UART contains two 64-byte FIFOs for receiving and transmitting data. Programmable baud rate, 1 or 2 stop bits, 5/6/7/8 data bits and parity status. There are generally three serial lines, Tx
[Microcontroller]
STM8L152 LCD module principle and driver
The STM8L182 integrates a driver module for an LCD with up to 320 pixels. The block diagram is as follows: 1. Configure the LCD clock source, division ratio, duty cycle, offset voltage, enable LCD port multiplexing function, definition, and enable LCD function. void LCD_Config(void) {     /* Enable RTC CLK */  
[Microcontroller]
STM8L152 LCD module principle and driver
The single chip microcomputer adds a PCF8574 module to realize the IIC mode to drive LCD1602
The PCF8574 module makes it possible to realize IIC driving LCD1602. The following figure is the connection circuit diagram of PCF8574 module and 1602: The actual connection method is as follows: If you want to use the PCF8574 module to implement IIC driving LCD1602, it is very necessary to first understand the ti
[Microcontroller]
The single chip microcomputer adds a PCF8574 module to realize the IIC mode to drive LCD1602
ARM Litian Electronics LPC2148 without font library 12864 displays multiple lines of multiple Chinese characters (serial)
It is similar to the previous article, showing multiple Chinese characters in one line, but with a few more lines of code (the colored part) and fonts. #include NXP/iolpc2148.h //pin macro definition #define SCLK 0x01 24 //595 clock terminal #define MISO 0x01 5 //Data input terminal #define MOSI 0x01 6 //Data outp
[Microcontroller]
ARM Litian Electronics LPC2148 without font library 12864 displays multiple lines of multiple Chinese characters (serial)
Low-Cost LCD TV Power Solution Based on the MAX17014
Maxim's MAX17014 is a low-cost multi-output LCD TV power controller that can generate the voltages required by TFT-LCD TVs and monitors from 12V. It includes buck and boost regulators, positive and negative charge pumps, two operational amplifiers, and a dual-mode logic control high-voltage control block.
[Power Management]
Low-Cost LCD TV Power Solution Based on the MAX17014
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号