Professional Documents
Culture Documents
Steps
1. Initialized TMOD for the required Timer0/1 and mode 0/1/2
2. Load the initial count value in register TL and TH
!"# %"&'(&)*#
Initial Value = Maximum value – [Required delay x +,
]+1
3. Start the timer using instruction SETB TR0/1 (bit of TCON register)
4. Wait until the timer flag TF0/1 of TCON register is set [Remember TF0/1 = 1
when timer overflows the maximum value]
5. Stop the timer using instruction CLR TR0/1 (bit of TCON register)
6. Clear TF0/1 flag
7. Repeat from step 2 for the next delay.
Read/Write(RW)
• This signal is used to write the data/cmd to LCD and reads the busy flag of
LCD.
• For write operation the RW should be LOW and for read operation the
R/W should be HIGH.
Register Select(RS)
• The LCD has two register namely a Data register and Command register.
• Any data that needs to be displayed on the LCD has to be written to the
data register of LCD.
• Command can be issued to LCD by writing it to Command register of
LCD.
•
This signal is used to differentiate the data/cmd received by the LCD.
•
If the RS signal is LOW then the LCD interprets the 8-bit info
as Command and writes it Command register and performs the action as
per the command.
• If the RS signal is HIGH then the LCD interprets the 8-bit info as data and
copies it to data register. After that the LCD decodes the data for
generating the 5x7 pattern and finally displays on the LCD.
Enable(EN):
• This pin is used to send the enable trigger to LCD.
• After selecting the data/cmd register, Selecting the Write operation. A
HIGH-to-LOW pulse has to be send on this enable pin which will latch the
info into the LCD register and triggers the LCD to act accordingly
• SCON is an 8-bit register used to program the start bit, stop bit, and data bits of
data framing.
• This register is used to configure baud rate, synchronization clock source.
• It contains status bits which indicate whether the data is transmitted completely
and any new data is received.
• SM0, SM1 - They determine the framing of data by specifying the number of bits
per character, and the start and stop bits
Program
# include <reg51.h>
void main()
{
unsigned chat table [13] = {128, 192, 238, 255, 238, 192, 128, 64, 17, 0, 17, 64, 128} ;
unsigned int i ;
P0 = 0x00 ; // output port
while(1)
{
for ( i = 0; i < 13 ; i ++)
P0 = table [i];
}
}
ORG 00h
MOV TMOD, #20h
MOV TH1, #0FDh or MOV TH1, #-3
MOV SCON, #50h
SETB TR1
Again: MOV R2, #09
MOV DPTR, #Msg
Back: CLR A
MOVC A, @A+DPTR
ACALL Send
INC DPTR
DJNZ R2, Back
SJMP Again
END
1 1 0 0 0 08
2 0 1 0 0 04
3 0 0 1 0 02
4 0 0 0 1 01
#include <reg51.h>
void delay (unsigned int x)
{
for( ; x>0 ; x-- );
}
void main ()
{
P0=0x00; // output
while(1)
{
P1 = 0x11;
delay(500);
P1 = 0x22;
delay(500);
P1 = 0x44;
delay(500);
P1 = 0x88;
delay(500);
}
}