Hello Readers:
I have started this blog to show you Embedded C programming for 8051 family microcontroller using KEIL compiler. The KISS philosophy is used to write this tutorial. What is KISS? Keep It Simple, Stupid!
This program displays “Hi!” on LCD screen continuously. Here LCD is configured for two lines but using only one line. Note that R/W [Read/Write] pin is connected permanently to ground [in hardware] as always write operation is used in this program.
Code explanation:
Line 16: This command configures LCD for 2 line 5x7 dot matrix.
Line 18: This command says display ON, cursor blinking.
Line 20: This command clears the display.
Line 22: This command shifts cursor to right.
Line 24: This command takes cursor to line1, position 6.
Line 26: This command sends ‘H’ letter to LCD.
Line 28: This command sends ‘i’ letter to LCD.
Line 30: This command sends ‘!’ letter to LCD.
Line 35: This lcdcmd() function sends parameter commands to LCD.
Line 46: This lcddata() function sends parameter data to LCD.
Line 57: This MSDelay() function supplies delay between each command execution.
After typing the code, press F7 or click Project->Build Target for building the source code. If there are no typical errors file will build successively and shows zero errors and zero warnings.
Now enter into debug mode by pressing Ctrl+F5 or click Debug->Start/Stop Debug Session menu. Our program is sending “Hi” characters to Port 1 continuously. So we want to watch the Port 1 pins while running this program for changing values. To get Port 1 tab click Peripherals->I/O Ports->Port 1 text.
Run the program by pressing F5 or clicking Debug->Run. You can see the hexa values of ‘H’,’I’ & ‘!’ characters on Port 1 tab continuously in binary form. If you generate HEX file of this program, burn it into your target chip’s memory using suitable uploader and connecting LCD to Port 1 you can have message “Hi” on LCD screen. To stop running the program press red ‘x’ mark icon or click Debug->Stop.
...till next post bye-bye & take care.
No comments:
Post a Comment