Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 2: Demonstrate Basic LCD operation 1. Create a new project to demonstrate L

ID: 1766293 • Letter: P

Question

Part 2: Demonstrate Basic LCD operation 1. Create a new project to demonstrate LCD operation 2. Create a source file. Insert the sample LCD code provided on Blackboard. Configure the code to display "EE 3310 2018" and "LCD Tutorial" centered on your display. Instructor/GTA's Initials: Part 3: Identify the corners of the display Modify your display to place an "0 in each of the four corners of the display. Send commands to the display to instruct the display to cause each 0 to blink in sequence around the board. In other words, Top Left blink, Top Right blink, Bottom Right blink, Bottom Left blink, then continue. Instructor/GTA's Initials: Part 4: Display Information Modify the code to display your name and Student ID, centered in the display. If the last digit of your student ID is even, put your name on the top row. I the last digit of your name is odd, put your name in the bottom row Your Name Your Student ID Instructor/GTA's Initials: Part 5: Demonstrate Counting Reprogram the display to count in hex from 0x00 to 0x20, and then back to 0x00 again with the left character centered on the top row. The cycle should repeat continuously until power is removed. Add a timer to your code so that the digits change at a 0.5 second rate(delay ½ second between counts). Instructor/GTA's Initials: Part 6: Demonstrate Scrolling Reprogram the display to scroll the alphabet (Upper Case only) from right to left across the screen, starting on the top row. The first character to display will be "A which first appears at the top/right of the screen. When the first letter (A") disappears from the top row it should reappear 1 cycle later in the right-most position of the bottom row and scroll from right to left. Write your code in a loop so that this process repeats, appearing at the right of the top row as it scrolls off the bottom row. Reprogram your timer so the characters scroll at a 0.25 second rate (delay 1/4 second between counts). Instructor/GTA's Initials:

Explanation / Answer

Below are the codes for the LCD operation in C-language keeping the microcontroller AT89C52 as the controlling device for LCD. The cross compiler is Keil.

***********************************************************************************************

#include <AT89X52.H>

#define ON 1

#define OFF 0

#define LED P1_2

void CheckLCDBusyFlag(void);

void LCDData(unsigned char Dat);

void LCDCmd(unsigned char Cmd);

void Position(unsigned char Pos);

void InitLCD(void);

void ClrScreen(void);

void Display(unsigned char Add);

unsigned char DispString[16];

#define ROW_1 1

#define ROW_2 0

#define LCD_EN P2_7

#define LCD_RW P2_6

#define LCD_RS P2_5

#define LCD_DATA P0

#define HIGH 1

#define LOW 0

#define RD 1

#define WR 0

#define RS_DATA 1

#define RS_CMD 0

void CheckLCDBusyFlag(void)

{

LCD_DATA = 0xFF;

LCD_RS = RS_CMD;

LCD_RW = RD;

LCD_EN = HIGH;

while(LCD_DATA & 0x80)

{

}

LCD_EN = HIGH;

}

void LCDData(unsigned char Dat)

{

CheckLCDBusyFlag();

LCD_RS = RS_DATA;

LCD_RW = WR;

LCD_DATA = Dat;

LCD_EN = LOW;

LCD_EN = HIGH;

LCD_RW = HIGH;

}

void LCDCmd(unsigned char Cmd)

{

CheckLCDBusyFlag();

LCD_RS = RS_CMD;

LCD_RW = WR;

LCD_DATA = Cmd;

LCD_EN = LOW;

LCD_EN = HIGH;

LCD_RW = HIGH;

}

void InitLCD(void)

{

LCD_EN = HIGH;

LCDCmd(0x38); // 8-bits Data Length, 16x2 Display Mode, 2 Lines of 16 Characters each

LCDCmd(0x0F); // Display ON and Cursetr Blink ON

LCDCmd(0x06); // Entry Mode Set

LCDCmd(0x80); // Clear Display

}   

void Position(unsigned char Pos)

{

LCDCmd(Pos);

}

void ClrScreen(void)

{

unsigned int cCnt;

for(cCnt = 0x80; cCnt < 0x8F; cCnt++)

{

Position(cCnt); LCDData(0x20);

Position(cCnt+0x40); LCDData(0x20);

}

}

void Display(unsigned char Add)

{

unsigned int cCnt,n=0;

for(cCnt = Add; cCnt < (Add + 16); cCnt++)

{

Position(cCnt); LCDData(DispString[n]);

}

}

void Delay(void)

{

for(c=0;c<500;c++)

{

TH0=0xFC; TL0=0x65;

TF0=0; TR0=1; while(!TF0){} TR0=0;

}

}

void main(void)

{

unsigned char t;

InitLCD();

ClrScreen();

/* Part # 2 */

sprintf(DispString," EE330 2018 "); Display(0x80); //Display the text in Top Line starting at 0x80

/* Part # 3 */

sprintf(DispString,"0 0"); Display(0x80); //Display 0 in top line at corners

sprintf(DispString,"0 0"); Display(0xC0); //Display 0 in bottom line at corners

/* Part # 4 */

sprintf(DispString," YOUR NAME "); Display(0x80); //Display Na,e in top line

sprintf(DispString," STUDENT ID "); Display(0xC0); //Display Student ID in bottom line

/* Part # 5 */

sprintf(DispString," ");

while(1)

{

for(t=0x00;t<0x20;t++)

{

sprintf(DispString," %X ",t); Display(0x80); //Display Na,e in top line

Delay(); //Delay for 500 msecs i.e. half second

}

}

}

***********************************************************************************************