12864 Read and Write Program

Publisher:yunhaoLatest update time:2015-08-10 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I have already said in the previous article that 12864 and LCD1602 are actually very similar. As long as you program according to the timing, there will generally be no problems.

If a problem occurs, it is usually not written strictly according to the sequence, especially in terms of delay.

Procedure: (Check the busy signal every time you read or write)

#define uchar unsigned char
#define uint unsigned int

#define Lcd_Bus P0 //MCU P2<------> LCM
sbit RS_12 = P3^5;
sbit RW_12 = P3^6;
sbit E_12 = P3^7;


void chk_busy(); //Check busy
void write_com(uchar cmdcode); //Write command address with row first and column last
void write_data(uchar Dispdata); // Write data
uchar read_data(void); //Read data The first byte needs to be read twice, that is, it needs to be read three times. The last two times are required. The first time, the address is automatically increased by 1, and the same is true for writing

void lcdreset(); //12864 initialization
void hzkdis(unsigned char code *s); //Display string
void Disp_Img(uchar code *img); //Drawing
void clrgdram(); //Clear the entire space
void clrscreen(); //Clear the screen, including the address

void ceshi() ; //First screen display

void chk_busy()
{ RS_12=0;
RW_12=1;
E_12=1;
Lcd_Bus=0xff;
while((Lcd_Bus&0x80)==0x80);
E_12=0;
}

void write_com(uchar cmdcode)
{
chk_busy();
RS_12=0;
RW_12=0;
E_12=1;
Lcd_Bus=cmdcode;
delay10(1);////////////////////Add appropriate delay when writing data
E_12=0;
delay10(1);;
}

void write_data(uchar Dispdata)
{
chk_busy();
RS_12=1;
RW_12=0;
E_12=1;
Lcd_Bus=Dispdata;
delay10(1); //Add appropriate delay when writing data
E_12=0;
delay10(1);
}

uchar read_data(void)
{
uchar da=0x00;
chk_busy();
Lcd_Bus=0xff;
RS_12=1;
RW_12=1;
E_12=1;
delay10(1);
da=Lcd_Bus;
E_12=0;
delay10(5);
return(da);
}

void lcdreset()
{ delayns(2);
write_com(0x30);
delay10(1); //Select basic instruction set
write_com(0x30); //Select 8-bit data stream
delay10(1);
write_com(0x0c); //Turn on display (no cursor, no inverting)
delay10(1);
write_com(0x01); //Clear display and set address pointer to 00H
delayns(1);
write_com(0x06); //Specify the cursor movement direction and display shift when reading and writing data
delayns(2);
}


void hzkdis(unsigned char code *s)
{ while(*s>0)
{ write_data(*s);
s++;
delay10(3);
}
}


void Disp_Img(uchar code *img)
{ unsigned int j=0;
unsigned char x,y,i;
for(i=0;i<9;i+=8)
for(y=0;y<32;y++)
for(x=0;x<8;x++)
{ write_com(0x36);//Function setting---8BIT control interface, expanded instruction set
write_com(y+0x80); //Row address
write_com(x+0x80+i); //Column address
write_com(0x30);
write_data(img[j++]);
write_data(img[j++]);
}

}


void clrgdram()
{ unsigned char x,y;
for(y=0;y<64;y++)
for(x=0;x<16;x++)
{ write_com(0x34);
write_com(y+0x80); // Row address
write_com(x+0x80); //Column address
write_com(0x30);
write_data(0x00);
write_data(0x00);
}
}



void clrscreen()
{
write_com(0x01);
delay10(3);
}

void ceshi()
{write_com(0x01); //Clear the display and set the address pointer to 00H
delay10(1);

write_com(0x80); //First line (if the address is: 80H, the first position of the first line of LCD will be displayed)
hzkdis(" Welcome ");

write_com(0x90); //The second line (if the address is: 90H, the first position of the second line of LCD is displayed)
hzkdis(" Here is group B 12 ");

write_com(0x88); //The third line (if the address is: 88H, that is, the first position of the second line of LCD is displayed)
hzkdis(" Constant Temperature Device Experiment ");

write_com(0x98); //The fourth line (if the address is: 98H, the first position of the second line of LCD will be displayed)
hzkdis(" Start now ");

 

}

Reference address:12864 Read and Write Program

Previous article:MSP430 AD conversion 12864 LCD display code
Next article:Precise delay program

Recommended ReadingLatest update time:2024-11-16 15:56

Single chip perpetual calendar (LCD12864, DS18B20, DS1302)
1. Introduction This circuit consists of AT89C51 minimum circuit board, LCD12864 display module, DS18B20 temperature module and DS1302 clock module. The main functions are: display real time and current temperature. 2. Operation Effect 3. Partial Code /*Want more projects private wo!!!*/ #include reg51.h #inclu
[Microcontroller]
Single chip perpetual calendar (LCD12864, DS18B20, DS1302)
LCD12864 driver
#include msp430g2553.h #include "lcd12864.h" #include "typedef.h"   #define cyCS BIT0 //P2.0, chip select signal #define cySID BIT1 //P2.1, serial data #define cyCLK BIT2 //P2.2, synchronous clock #define cyPORT P2OUT #define cyDDR P2DIR void Write_8bits(u8 W_bits) {       u8 i;       cyDDR |= cyCLK + cySID;   //设置输
[Microcontroller]
Simple calculator based on 51 single chip microcomputer 12864
I finally wrote the calculator. Actually, I had written it a long time ago, but I was busy with exams and lab projects, so I didn't have time to write a blog. Now I am at home during the winter vacation, and I can finally learn something quietly.     Below I will first write about the process of writing this program.
[Microcontroller]
STM8L drives I2C type 12864
principle I have never used a 12864 screen before, but I have used other types, and the principles are the same. 12864 is the name of a screen with 128x64 pixels. The screen has 64 rows and 128 columns; each Chinese character is 16x16, so such a screen can display up to 4x8 Chinese characters or 8x16 characters. I u
[Microcontroller]
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号