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);
}
Previous article:ATMEGA48 and DS1302 clock program
Next article:DS1302 AVR program (automatic calculation of the weekday from 2000 to 2099)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Why are the wild elephants heading north? Use your imagination and make bold predictions!
- Bose small speaker disassembly
- Guangdong Tonly Semiconductor suffered a confined space suffocation accident: 4 workers from the outsourcing unit died
- LIS3MDL evaluation board STEVAL-MKI137V1 data
- TI Embedded Live Month: In-depth exploration of new applications of embedded products in industry and automobiles. The first live broadcast today at 10:00
- Knowing the total resistance of the resistors, how big should two resistors be connected in parallel?
- The switching power supply needs to provide a 25A instantaneous high current and has overcurrent protection. How much overcurrent protection should be set?
- 【RPi PICO】Play MIDI music
- TI Embedded Live Month: In-depth exploration of new applications of embedded products in industry and automobiles.
- I want a Chinese specification sheet for OZ9902, SOP-16 pin