Project 2 – Hello World with Parallel LCD

Project 2 – Hello World with Parallel LCD

 

For project 2, we will show you how to interface the SK40C board will parallel 16×2 LCD display. The connection are simple and the coding are easy to learn. We are going to display the “Hello World” on the LCD display by just adding a library that has been done for you.

 

COMPONENT NEEDED

 

 

CONNECTION



SK40C have offer a extra connecter for user to directly plug in the LCD display. This have save the user a lot of time from soldering the LCD display.


The data pin of the LCD are connected to the PORTD while the RS of LCD are connected to RB4 and E of LCD are connected to RB5.Please refer to LCD datasheet1, LCD datasheet2 and SK40C user manual for further information.

 

ADDITIONAL INFORMATION


LIQUID CRYSTAL DISPLAY
Before start program the LCD, we have to know the function of each pin on the LCD display to avoid wrong connection.


RS – LOW (0), data bytes transfer are treated as command.

HIGH (1), character can be transfer to and from module.

R/W – LOW(0), write command or character data to the module.

HIGH(1), read character data or status information from its registers.

E – HIGH(1) to LOW(0), writing to display.

LOW(0) to HIGH(1), reading from display.

D0 to D7 – Eight data bus line.

 


There are numbers of cool experiment inside the LCD datasheet which have teach us how to entering the text, addressing, shifting the display, character entry mode, user-defined graphic, 4-bits data transfer.

 

              

 

 

LCD BACKLIGHT CONTROL

To make your LCD look cool, we can ON the backlight of the LCD by just put or solder a mini jumper to short LCD B/L.

 

 

LCD CONTRAST CONTROL

There is a potential meter who is purposely added for user to adjust the different contrast of LCD. Turn left or right to adjust the contrast level.

 

CODE OVERVIEW



Figure above have show that we have included an lcd.h and system.h file inside our main program. The reason we are doing this is to separated our code in different file and for easily to relocated back by user if got any error. To refer back the LCD program, all we need is double-click the lcd.c and it will show up.

 

 

What’s inside “lcd.c” & “lcd.h” ?
Inside lcd.c, we have already defined all the code that needed to control the LCD such as the coding in figure below:

As for lcd.h is an header file. These files allow programmers to separate certain elements of a program’s source code into reusable files. Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers. Programmers who wish to declare standardized identifiers in more than one source file can place such identifiers in a single header file, which other code can then include whenever the header contents are required.

system.h



In system.h, we use to give a name to a port using. Besides from defining the crystal frequency, in here, we have also define the PORT that required to use by LCD which is RB4, RB5 & PORTD.

 

lcd_initialize();
Before start to send any data to LCD, the LCD should be initialize 1st. The initialization process are such as, clear LCD display, cursor home, cursor on/off, display/cursor shift and function set.

 

lcd_home();
To make sure that the cursor is back to home. We need to send a command for it which is in binary 00000010.

 

lcd_putstr(“Hello World”)
Send a string to LCD data bus to display it on the screen. The symbol “” is mean what the word or text inside are in ASCII format. The compiler will automatically convert it to binary and send to the required port. Finally the texts Hello World will be display on the screen.

 

*If you want faster response from author, please do post your comment/inquiry/feedback in our technical forum as we seldom check the comments section in tutorial site 

 

ATTACHMENT

1. P2 User Manual.pdf
2. Project_2.code.zip

You can get the parts here: