Specification :
LCD type : LCD1602 (16*2)
IIC / I2C module soldered on LCD.
4 Pinout with VCC,GND,SDA,SDL
IIC Address : 0x27
Size : 82mm * 36mm* 18mm
Blue Background , White colour word display
IIC I2C Address Scanner Link :
1602A chip for the SPLC780 SPLC100 compatible with all chips mainstream chip, mainstream choice, backlight brightness uniformity, good display, excellent quality, after-sale security, shipping on time, welcome to buy .SPLC780 than the micro-core anti-static ability, Quality and stability, Taiwan genuine. Welcome to your purchase. The following is the basic information of 1602:
The following is the procedure for displaying the letter "A" at the position of the first character of the second line of the LCD module: ORG 0000H
RS EQU P3.7; determine the specific hardware connection
RW EQU P3.6; Determines how the specific hardware is connected
E EQU P3.5; determine the specific hardware connection
MOV P1, # 00000001B; clear screen and cursor reset
ACALL ENABLE; Calls the write command subroutine
MOV P1, # 00111000B; Set the display mode: 8-bit 2-line 5x7 dot matrix
ACALL ENABLE; Calls the write command subroutine
MOV P1, # 00001111B; The display is on and the cursor is on and the cursor is allowed to flash
ACALL ENABLE; Calls the write command subroutine
MOV P1, # 00000110B; text does not move, the cursor automatically move to the right
ACALL ENABLE; Calls the write command subroutine
MOV P1, # 0C0H; write display start address (second line first position)
ACALL ENABLE; Calls the write command subroutine
MOV P1, # 01000001B; letter A code
SETB RS; RS = 1
CLR RW; RW = 0; ready to write data
CLR E; E = 0; Execute the display command
ACALL DELAY; to determine whether the LCD module is busy?
SETB E; E = 1; display is complete, the program stops
AJMP $
ENABLE:
CLR RS; write subroutine of control commands
CLR RW
CLR E
ACALL DELAY
SETB E
RET
DELAY:
MOV P1, # 0FFH; determine whether the liquid crystal display is busy subroutine
CLR RS
SETB RW
CLR E
NOP
SETB E
JB P1.7, DELAY; If P1.7 is busy, it is busy waiting for it
RET
END
The program at the beginning of the LCD module function was initialized set, agreed to the display format. Note that when the characters are displayed when the cursor is automatically shifted to the right, without manual intervention, each input instructions are called to determine whether the LCD module is busy subroutine DELAY, and then enter the display location of the address 0C0H, and finally enter the characters to display A code 41H The
SMC1602A (16 * 2) Analog port wiring
Link diagram:
-------------------------------------------------- -
LCM ---- 51 | LCM ------51 | LCM ------ 51 |
------------------------------------------------ |
| DB0 ----- P1.0 | DB4 ----- P1.4 | RW ------- P2.0 |
| DB1 ----- P1.1 | DB5 ----- P1.5 | RS ------- P2.1 |
| DB2 ----- P1.2 | DB6 ----- P1.6 | E -------- P2.2 |
| DB3 ----- P1.3 | DB7 ----- P1.7 | VLCD Connect 1K Resistor to GND |
-------------------------------------------------- -
[Note: AT89S52 using 12M crystal]
================================================== =========== * /
#define LCM_RW P2_0 // define the pin
#define LCM_RS P2_1
#define LCM_E P2_2
#define LCM_Data P1
#define Busy 0x80 // is used to detect the Busy identity in the LCM status word
#i nclude
Void WriteDataLCM (unsigned char WDLCM);
Void WriteCommandLCM (unsigned char WCLCM, BuysC);
Unsigned char ReadDataLCM (void);
Unsigned char ReadStatusLCM (void);
Void LCMInit (void);
Void DisplayOneChar (unsigned char X, unsigned char Y, unsigned char DData);
Void DisplayListChar (unsigned char X, unsigned char Y, unsigned char code * DData);
Void Delay5Ms (void);
Void Delay400Ms (void);
Unsigned char code uctech [] = {"uctech"};
Unsigned char code net [] = {"uctech.icpcn.com"};
Void main (void)
{
Delay400Ms (); // start waiting, wait for LCM to talk about working status
LCMInit (); // LCM is initialized
Delay5Ms (); // delay for a moment (no)
DisplayListChar (0, 5, uctech);
DisplayListChar (0, 0, net);
ReadDataLCM (); // test sentence is meaningless
While (1);
}
// write data
Void WriteDataLCM (unsigned char WDLCM)
{
ReadStatusLCM (); // detect busy
LCM_Data = WDLCM;
LCM_RS = 1;
LCM_RW = 0;
LCM_E = 0; // If the crystal speed is too high, you can add a small delay after this
LCM_E = 0; // delay
LCM_E = 1;
}
// write instructions
Void WriteCommandLCM (unsigned char WCLCM, BuysC) // BuysC is 0
{
If (BuysC) ReadStatusLCM (); // detect busy as needed
LCM_Data = WCLCM;
LCM_RS = 0;
LCM_RW = 0;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
}
// read the data
Unsigned char ReadDataLCM (void)
{
LCM_RS = 1;
LCM_RW = 1;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
Return (LCM_Data);
}
// read the state
Unsigned char ReadStatusLCM (void)
{
LCM_Data = 0xFF;
LCM_RS = 0;
LCM_RW = 1;
LCM_E = 0;
LCM_E = 0;
LCM_E = 1;
While (LCM_Data & Busy); // detect busy signals
Return (LCM_Data);
}
Void LCMInit (void) // LCM initialization
{
LCM_Data = 0;
WriteCommandLCM (0x38,0); // Three display mode settings, do not detect busy signals
Delay5Ms ();
WriteCommandLCM (0x38,0);
Delay5Ms ();
WriteCommandLCM (0x38,0);
Delay5Ms ();
WriteCommandLCM (0x38,1); // display mode setting, start asking for a busy signal every time
WriteCommandLCM (0x08,1); // close the display
WriteCommandLCM (0x01,1); // display clear screen
WriteCommandLCM (0x06,1); // display the cursor movement settings
WriteCommandLCM (0x0C, 1); // display on and cursor settings
}
// Show a character at the specified location
Void DisplayOneChar (unsigned char X, unsigned char Y, unsigned char DData)
{
Y & = 0x1;
X & = 0xF; // limit X can not be greater than 15, Y can not be greater than 1
If (Y) X | = 0x40; // Address code + 0x40 when the second line is to be displayed;
X | = 0x80; // Calculate the script
WriteCommandLCM (X, 0); // do not detect the busy signal here, send the address code
WriteDataLCM (DData);
}
// Show a string of characters at the specified location
Void DisplayListChar (unsigned char X, unsigned char Y, unsigned char code * DData)
{
Unsigned char ListLength;
ListLength = 0;
Y & = 0x1;
X & = 0xF; // limit X can not be greater than 15, Y can not be greater than 1
While (DData [ListLength]> 0x20) // exit if the string is reached
{
If (X <= 0xF) // The X coordinate should be less than 0xF
{
DisplayOneChar (X, Y, DData [ListLength]); // Show a single character
ListLength ++;
X ++;
}
}
}
// 5ms delay
Void Delay5Ms (void)
{
Unsigned int TempCyc = 5552;
While (TempCyc--);
}
// 400ms delay
Void Delay400Ms (void)
{
Unsigned char TempCycA = 5;
Unsigned int TempCycB;
While (TempCycA--)
{
TempCycB = 7269;
While (TempCycB--);
};