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

Look at the data sheet for the Newhaven Display NHD-0 1 08BZ-RN-YBW-3V3 . Write

ID: 2084759 • Letter: L

Question

Look at the data sheet for the Newhaven Display NHD-0 1 08BZ-RN-YBW-3V3 . Write a

software function using the LCD hardware in Section 4.7.1 that reads the LCD status bit. Use

this function to convert LCD _OutChar from blind cycle to busy wait.

RS R/W ration Write a command to the LCD instruction register Read Busy Flag (bit 7) Write data to the LCD data buffer Read data from the LCD to the microcontroller 0 0 Table 4.4. Two control signals specify the type of access to the LCD VS (ground) 2 Vdd(power +3.3 V 1 by 8 LCD display Vee (contrast) 5 by 8 bit font 4 PG0 PG1 PG2 PFO PFI PF2 PF3 PF4 PF5 PF6 PF7 DBO 8 DB1 HD44780U or ST7066U controller DB2 DB3 DB4 DB5 DB6NHD-0108BZ-RN-YBw-3V3 DB7 10 12 13 Newhaven Display International, Inc.

Explanation / Answer

/*LCD interfacing program*/

/*LCD_outchar from blind cycle to busy wait*/

#include"p18f4520.h"
#include"delays.h"
#include"lcd.h"

void LCD_init(void){
EN=LOW;
RS=LOW;
LCD_port=0x00;
LCD_reset();
LCD_cmd(CLRSCR);
Delay10KTCYx(50);
LCD_cmd(MODE_4BIT);
Delay10KTCYx(50);
LCD_cmd(DISPLAY_ON | CURSOR_OFF);
Delay10KTCYx(50);
LCD_cmd(CURSOR_INC);
Delay10KTCYx(50);
LCD_cmd(LCD_LINE1);
Delay10KTCYx(50);

}

void LCD_reset(void)
{
Delay10KTCYx(2);
LCD_port=0x03;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;

Delay10KTCYx(1);
LCD_port=0x03;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;

Delay1KTCYx(1);
LCD_port=0x03;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;

Delay1KTCYx(1);
LCD_port=0x02;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;
Delay1KTCYx(1);
}

void LCD_data(unsigned char data)
{
unsigned char temp;
temp=data;
RS=HIGH;
//sends the upper four bits
temp=temp>>4;
LCD_port=temp;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;

//sends the lower 4 bits
temp=data;
LCD_port=temp;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;
}

void LCD_cmd(unsigned char cmd)
{
unsigned char temp;
TRISD = 0x00;
RS = LOW;
LCD_port_dir = 0x00;
temp=cmd;

//sends the upper four bits
temp=temp>>4;
LCD_port=temp;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;

//sends the lower 4 bits
temp=cmd;
LCD_port=temp;
EN=HIGH;
Delay10KTCYx(50);
EN=LOW;
}

void LCD_string(const rom char *buffer)
{
while(*buffer) // Write data to LCD up to null
{
Delay10KTCYx(50);
LCD_data(*buffer); // Write character to LCD
buffer++; // Incrementbuffer
}
}

void LCD_blink(void)
{
LCD_cmd(DISPLAY_OFF);
Delay10KTCYx(255);
Delay10KTCYx(255);
LCD_cmd(DISPLAY_ON);
Delay10KTCYx(255);
Delay10KTCYx(255);
LCD_cmd(DISPLAY_OFF);
Delay10KTCYx(255);
Delay10KTCYx(255);
LCD_cmd(DISPLAY_ON);
Delay10KTCYx(255);
Delay10KTCYx(255);
}

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

//lCD program..................
void init()
//initialize the LCD
{
P3 = 1;
P1 = 1;
RST = 0; //RESET
delay(2);
RST = 1; //end reset
delay(20);
Writecom(0x30); //wake up
delay(2);
Call writecom(0x30); //wake up
Call writecom(0x30); //wake up
Call writecom(0x39); //function set
Call writecom(0x14); //internal osc frequency
Call writecom(0x56); //power control
Call writecom(0x6D); //follower control
Call writecom(0x70); //contrast
Call writecom(0x0C); //display on
Call writecom(0x06); //entry mode
Call writecom(0x01); //clear
delay(10);
}
void writecom(int d)
{
CS = 0; //CS
RS = 0; //A0 = Command
for(serialcounter = 1; serialcounter <= 8; serialcounter++) //send 8 bits
{
if((d&0x80)==0x80) //get only the MSB
SI=1; //if 1, then SI=1
else
SI=0; //if 0, then SI=0
d=(d<<1); //shift data byte left
SCL = 0;
SCL = 1;
SCL = 0; //SCL
}
CS = 1;
}
void writedata(int d)
{
CS = 0; //CS
RS = 1; //A0 = Data
for(serialcounter = 1; serialcounter <= 8; serialcounter++) //send 8 bits
{
if((d&0x80)==0x80) //get only the MSB
SI=1; //if 1, then SI=1
else
SI=0; //if 0, then SI=0
d=(d<<1); //shift data byte left
SCL = 0;
SCL = 1;
SCL = 0; //SCL
}
CS = 1;
}

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote