100% found this document useful (1 vote)
906 views

Oasis Technologies PVT - LTD: Return

This document contains code for initializing and controlling an LCD display. It includes functions for configuring GPIO pins for the LCD, sending command and data to the LCD, clearing the display, moving the cursor, and displaying a string of text or numeric value on the LCD. The functions set the appropriate pins as outputs, send command and data bytes to the LCD by setting the enable pin high and low, and convert numeric values to ASCII before display.

Uploaded by

rpsirius1
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
906 views

Oasis Technologies PVT - LTD: Return

This document contains code for initializing and controlling an LCD display. It includes functions for configuring GPIO pins for the LCD, sending command and data to the LCD, clearing the display, moving the cursor, and displaying a string of text or numeric value on the LCD. The functions set the appropriate pins as outputs, send command and data bytes to the LCD by setting the enable pin high and low, and convert numeric values to ASCII before display.

Uploaded by

rpsirius1
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Oasis Technologies Pvt.

Ltd

LCDInit

Wait for the LCD to get ON


waitOnPowerOnForLCD ()
Configure the pins connected to LCD as general purpose I/O
PINSEL0 = PINSEL0 & ~(0x00FF0000) (modify the PINSEL0 reg)
PINSEL2 = 0x00 (update PINSEL2 reg).
Set the direction of the selected pins as OUTPUT]
IODIR0 = IODIR0 | 0x00001800;
IODIR1 = IODIR1 | 0X00FF0000;
Function Set command for LCD
lcdcmd (0x38)
Display On command for LCD
lcdcmd (0x0e);
Clear Display command for LCD
lcdcmd(0x01);
Entry mode set command for LCD
lcdcmd (0x06);
Set DDRAM address command for LCD
lcdcmd (0x80);

return

cursratline1clm1

Set DDRAM address command for LCD


lcdcmd (0x80);

return

inccursor

Entry mode set command for LCD


lcdcmd (0x06); (increment the cursor)

return

www.oasistech.co.in
Oasis Technologies Pvt.Ltd

clrscreen

Clear Display command for LCD


lcdcmd(0x01);
Set DDRAM address command for LCD
lcdcmd (0x80

return

lcdcmd

Make the RS line =0 to write into the command reg of the LCD
IOCLR0 = IOCLR0 | 0x00000800

Clear all the data lines selected for the LCD.


IOCLR1 = IOCLR1 | 0x00ff0000.

Align the data properly into the register.


cmddata = cmddata << 16 (to set the appropriate lines)

Write the command data on the data lines.


IOSET1 = IOSET1 | cmddata.

. Clear the Enable Pin.


IOCLR0 = IOCLR0 | 0x00001000. Delay for some time.

Set the Enable pin.


IOSET0 = IOSET0 | 0x00001000 Delay for some time.

Clear the Enable Pin.


IOCLR0 = IOCLR0 | 0x00001000.

return

www.oasistech.co.in
Oasis Technologies Pvt.Ltd

lcddata

Make the RS line =1 to write into the data reg of the LCD
IOSET0 = IOSET0 | 0x00000800

Clear all the data lines selected for the LCD.


IOCLR1 = IOCLR1 | 0x00ff0000.

Align the data properly into the register.


outdata = outdata << 16 (to set the appropriate lines)

Write the LCD data on the data lines.


IOSET1 = IOSET1 | outdata.

. Clear the Enable Pin.


IOCLR0 = IOCLR0 | 0x00001000. Delay for some time.

Set the Enable pin.


IOSET0 = IOSET0 | 0x00001000 Delay for some time.

Clear the Enable Pin. IOCLR0 = IOCLR0 | 0x00001000.


inccursor();
inccursor();

return

DisplayLCD

N
length of string !=0
return

Call lcddata with the value=character..


Increment string pointer

www.oasistech.co.in
Oasis Technologies Pvt.Ltd

PrintData

Count =0;
Val = user specified count.

N
Val /10 ! = 0

printstr[count] = val % 10;


val = val / 10; count++;

printstr[count++] = val % 10;

Count ! = 0;

val = printstr[--count];
asciidata(val);

return

www.oasistech.co.in
Oasis Technologies Pvt.Ltd

asciidata

Add 30 to the parameter received


outdata += 0x30

Make the RS line =1 to write into the data reg of the LCD
IOSET0 = IOSET0 | 0x00000800

Clear all the data lines selected for the LCD.


IOCLR1 = IOCLR1 | 0x00ff0000.

Align the data properly into the register.


outdata = outdata << 16 (to set the appropriate lines)

Write the LCD data on the data lines.


IOSET1 = IOSET1 | outdata.

. Clear the Enable Pin.


IOCLR0 = IOCLR0 | 0x00001000. Delay for some time.

Set the Enable pin.


IOSET0 = IOSET0 | 0x00001000 Delay for some time.

Clear the Enable Pin.


IOCLR0 = IOCLR0 | 0x00001000.

return

www.oasistech.co.in

You might also like