LCD 12232F serial port C51 program (ST7920)

Publisher:DazzlingSmileLatest update time:2017-12-17 Source: eefocusKeywords:LCD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Because the 12232F display is commonly used, but what we usually see are some parallel port assembly programs, and there is no parallel port program corresponding to 12232F, and the serial port C51 program is very rare. In order to facilitate everyone's use, this site has debugged it out. Please give your advice! 

/**********************************************************/  
/* */  
/* 12232F serial port driver C51, 11.0592M crystal */  

/*Things to note when using this LCD: */  
/*Be sure to connect a 20K potentiometer between the three pins VO, VDD and VSS. */  
/*The middle pin of the potentiometer is connected to VO, and the other two pins are connected to VDD and VSS. */  
/*Then adjust the size of the potentiometer until there is a display. If it is not connected, */  
/*the display may be dark, with nothing displayed, and there is no response to the command  
. I have tested this program. Welcome to give your comments. */  
/******************************************************/  
#include   
#include  



#define uint unsigned int  
#define uchar unsigned char 



/*12232f  PIN s define*/  
sbit CS=P1^5;  
sbit SID=P1^6;  
sbit SCLK=P1^7;  



void delay_1ms(uint x)  
{  
uint j;  
uchar i;  
(j=0;j{  
for(i=0;i<120;i++);  
}  




void send_command(uchar command_data)  
{  
uchar i;  
uchar i_data,data1,data2;  
i_data=0xf8;  
delay_1ms(10);  
CS=1;  
SCLK=0;  
for(i=0;i<8;i++)  
{  
SID=(bit)(i_data&0x80);  
SCLK=0;  
SCLK=1;  
i_data=i_data<<1;  
}  
i_data=command_data;  
i_data&=0xf0;  
for(i=0;i<8;i++)  
{  
SID=(bit)(i_data&0x80);  
SCLK=0;  
SCLK=1;  
i_data=i_data<<1;  
}  
i_data=command_data ;  
data1=i_data&0xf0;  
data2=i_data&0x0f;  
data1>>=4;  
data2<<=4;  
i_data=data1|data2;  
i_data&=0xf0;  
for(i=0;i<8;i++)  
{  
SID=(bit)(i_data&0x80);  
SCLK=0;  
SCLK=1;  
i_data=i_data<<1;  
}  
CS=0;  
}  

void send_data(uchar command_data)  
{  
uchar i;  
uchar i_data,data1,  data2;
i_data=0xfa;  
delay_1ms(10);  
CS=1;  
for(i=0;i<8;i++)  
{  
SID=(bit)(i_data&0x80);  
SCLK=0;  
SCLK=1;  
i_data=i_data<< 1;  
}  
i_data=command_data;  
i_data&=0xf0;  
for(i=0;i<8;i++)  
{  
SID=(bit)(i_data&0x80);  
SCLK=0;  
SCLK=1;  
i_data=i_data<<1;  
}  
i_data =command_data;  
data1=i_data&0xf0;  
data2=i_data&0x0f;  
data1>>=4;  
data2<<=4;  
i_data=data1|data2;  
i_data&=0xf0;  
for(i=0;i<8;i++)  
{  
SID=(bit)(i_data&0x80);  
SCLK=0;  
SCLK=1;  
i_data=i_data<<1;  
}  
CS=0;  




void lcd_init()  
{  
uchar command_data;  
delay_1ms(100);  
command_data=0x30;  
send_command(command_data); /*Function setting: send 8 bits of data at a time, basic instruction set*/  
command_data=0x04;  
send_command(command_data); /*Point setting: display character/cursor shifts from left to right, DDRAM address increases by 1*/  
command_data=0x0f;  
send_command(command_data); /*Display setting: turn on display, display cursor, current display bit flashes in reverse*/  
command_data=0x01;  
send_command(command_data); /*Clear DDRAM*/  
command_data=0x02;  
send_command(command_data); /*Return DDRAM address*/  
command_data=0x80;  
send_command(command_data); /*Set the display address to 0X80, which is the first position of the first line*/  




void display_cpubbs()  
{  
uchar command_data;  
while(1)  
{  
command_data=0x01;  
send_command(command_data); /*Clear DDRAM*/  
command_data=0x80;  
send_command(command_data); /*Set the display address to 0X80, which is the first position of the first line*/   command_data=0x68; /* The encoding
of the word “h” */   send_data(command_data);   command_data=0x74;   send_data(command_data); /*The encoding of the word “t”*/   command_data=0x74;   send_data(command_data); /*The encoding of the word “t”*/   command_data=0x70;   send_data(command_data); /*The encoding of the word “p”*/   command_data=0x3a;   send_data(command_data); /*The encoding of the word “:”*/   command_data=0x2f;   send_data(command_data); /*Code for “/”*/   command_data=0x2f;   send_data(command_data); /*Code for “/”*/   command_data=0x57;   send_data(command_data); /*Code for “w”*/   command_data=0x57;   send_data(command_data); /*Code for “w”*/   command_data=0x57;   send_data(command_data); /*Code for “w”*/   command_data=0x2e;   send_data(command_data); /*Code for “.”*/   command_data=0x63;   send_data(command_data); /*Code for “c”*/   command_data=0x70;   send_data(command_data); /*Code for “p”*/   command_data=0x75;   send_data(command_data); /*Code for “u”*/   command_data=0x62;   send_data(command_data); /*code of “b”*/   command_data=0x90;   send_command(command_data); /*set the display address to 0X90, which is the first position of the second line, because the first line is full*/   command_data=0x62;   send_data(command_data); /*code of “b”*/   command_data=0x73;   send_data(command_data); /*code of “s”*/   command_data=0x2e;   send_data( command_data); /*code of “.”*/   command_data=0x63;   send_data(command_data); /*code of “c”*/   command_data=0x6f;   send_data(command_data); /*code of “o”*/   command_data=0x6d;   send_data(command_data); /*Encoding of the word “m”*/   delay_1ms(3000);   command_data=0x01;  
















































send_command(command_data); /*Clear DDRAM*/  
command_data=0x80;  
send_command(command_data); /*Set the display address to 0X80, which is the first position of the first line*/  

command_data=0xbb;  
send_data(command_data);  
command_data=0xb6;  
send_data(command_data); /*The code of the word “欢”*/  
command_data=0xd3;  
send_data(command_data);  
command_data=0xad;  
send_data(command_data); /*The code of the word “迎”*/  
command_data=0xb7;  
send_data(command_data);  
command_data=0xc3;  
send_data(command_data); /*The code of the word “访”*/  
command_data=0xce;  
send_data(command_data);  
command_data=0xca;  
send_data(command_data); /*Code for the word “问”*/  
command_data=0x90;  
send_command(command_data); /*Set the display address to 0X90, which is the first position of the second line, because the first line is full*/  
command_data=0x63;  
send_data(command_data); /*Code for the word “c”*/  
command_data=0x70;  
send_data(command_data); /*Code for the word “p”*/  
command_data=0x75;  
send_data(command_data); /*Code for the word “u”*/  
command_data=0x62;  
send_data(command_data); /*Code for the word “b”*/  
command_data=0x62;  
send_data(command_data); /*Code for the word “b”*/  
command_data=0x73;  
send_data(command_data); /*Code for the word “s”*/  
command_data=0xc2;  
send_data(command_data);  
command_data=0xdb;  
send_data(command_data); /*The encoding of the word “论”*/  
command_data=0x CC ;  
send_data(command_data);  
command_data=0xb3;  
send_data(command_data); /*The encoding of the word “坛”*/  
delay_1ms(3000);  
}  




main()  
{  
uchar command_data;  
lcd_init();  
display_cpubbs();  
while(1);  


Keywords:LCD Reference address:LCD 12232F serial port C51 program (ST7920)

Previous article:ATMEGA48 and DS1302 clock program
Next article:DS1302 AVR program (automatic calculation of the weekday from 2000 to 2099)

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号