code show as below:
//filename:global.h
#include
//#include
//#include
#define uchar unsigned char
#define uint unsigned int
//filename:T6963C.H
#define DATA_PORT P0
//-------------------------------------------
// Pin definition
//------------------------------------------
sbit CD=P2^0; //Data (L)/Command (H) selection
sbit WRIT=P2^1; //write, low level is valid
sbit CE=P2^2; //Enable, low level is effective
//===========================================
// Function declaration
//-------------------------------------------
void delay_lcd(char);
void write_data(char);
void write_text(char);
void write_com(char);
void clr_lcd(char,char,int);
void lcd_init_graph();
void lcd_init_text();
void text_out(char a);
int asc2lcd(int asc);
//--------------------------------------------
// Write data function
//--------------------------------------------
void write_data(char dat){
CD=0; //data
CE=0; //LCD enable
WRIT=0; //write
DATA_PORT=dat; //Send data to port P
delay_lcd(1); //Add delay when the crystal oscillator is high
WRIT=1; //Close writing
CE=1; //disable enable
}
//--------------------------------------------
// Write data function
//--------------------------------------------
void write_text(char text){
CD=0; //data
CE=0; //LCD enable
WRIT=0; //write
DATA_PORT=text; //Send data to port P
delay_lcd(1); //Add delay when the crystal oscillator is high
WRIT=1; //Close writing
CE=1; //disable enable
}
//--------------------------------------------
// Write command function
//--------------------------------------------
void write_com(char com){
CD=1; //command
CE=0;
WRIT=0;
DATA_PORT=com;
delay_lcd(1); //Add delay when the crystal oscillator is high
WRIT=1;
CE=1;
}
void clr_lcd(char x,char y,int length){
int i,place;
place=x*30+y;
write_data(place&0xff);
write_data(place/256);
write_com(0x24); //Set
for(i=0;i
write_data(0xff); //Write a space and clear the screen
write_com(0xb2); //turn off automatic writing
}
//--------------------------------------------
// LM4229 initialization function
//--------------------------------------------
void lcd_init_graph(){
write_data(0); //Graphics first address
write_data(0);
write_data(30);
write_data(0);
write_com(0x43); //Graphics area settings
write_com(0x80); //Set to OR mode
write_com(0x98); //Turn off text display and turn on graphic display
}
//--------------------------------------------
// LM4229 initialization function
//--------------------------------------------
void lcd_init_text(){
write_data(0);
write_data(0);
write_com(0x40); //set text home address
write_data(30);
write_data(0);
write_com(0x41); //set text area;
write_com(0x84); //text attribute mode
write_com(0x94); //text on graphic off
}
void cursor_on(){
write_com(0xA0);
write_com(0x93);
write_com(0x94); //text on graphic off
}
void print_text(char x,char y,char a){
int place;
place=x*30+y;
write_data(place&0xff); //write address lower 8 bits
write_data(place/256); //write address high 8 bits
write_com(0x24); //Set address
write_com(0xb0); //Set data to be written automatically
write_text(a);
write_com(0xb2); //Automatic reset
}
void text_out(char a){
write_com(0xb0); //Set data to be written automatically
write_text(a);
write_com(0xb2); //Automatic reset
}
void text_location(int place){
write_data(place&0xff); //write address lower 8 bits
write_data(place/256); //write address high 8 bits
write_com(0x24); //Set address
}
void print_string(char* str){
int i;
int ch;
for(i=0;str[i]!=0;i++)
{
ch=asc2lcd(str[i]);
text_out(ch);
}
}
//--------------------------------------------
// Delay function
//--------------------------------------------
void delay_lcd(uchar t){
for(;t!=0; t--);
}
//===================================================
int asc2lcd(int asc){
uint r;
r=asc-32;
return r;
}
//latest revise:2010-2-11
//by:alex shoal
//email:alex.shoal@gmail.com
main(){
int place=5;
char ch=0x00;
lcd_init_text();
text_location(place);
print_string("Hello,china! ");
while(1);
}
Previous article:Microcontroller LCD Experiment 2
Next article:Microcontroller keyboard scanning experiment
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
Guess you like
- Without exaggeration or criticism, SS5 is the smoothest and most user-friendly Eclipse-based IDE I have ever used.
- [2022 Digi-Key Innovation Design Competition] 4. ESP32-S2-Kaluga-1 running LVGL
- Share a domestic 32-bit M3 microcontroller CH32F103
- Those who work on weekends, please come and gather
- Dear electronic design experts, please come and have a look
- TMS320-F2818 DC resistance comparator
- Which transistor-controlled MOS tube switch circuit is better?
- In-depth Linux kernel architecture (Chinese version)
- Ask for points
- [GD32E503 Review] + Transplanting TencentOS-tiny