Docsity

LCD Interfacing-Interfacing Microprocessor-Project Report, Study Guides, Projects, Research of Microprocessor and Interfacing

Toggle sidebar
bg1
Page|1
Objective:
To implement LCD interfacing, and understanding the initialization and working of LCD.
LCD Interfacing:
LCD interfacing is the communication or the interaction between the microcontroller and
the LCD. In this project we are using HD44780 Hitachi chipset compatible LCD’s for
interfacing with ATmega16.
Equipment:
Components Quantity
Bread Boards 2
6 pins on/off switch
1
16MHz crystal oscillator
1
NPN SC1815 transistor
1
1µF Polarized capacitor
1
DB9 female plug 1
22pF non-polarized
capacitors
2
Connecting wires As required
green colored led 1
AT Mega 16 controller
1
Bread Boards 2
10kΩ resistor 1
100kΩ resistor 1
1kΩ resistor 1
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download LCD Interfacing-Interfacing Microprocessor-Project Report and more Study Guides, Projects, Research Microprocessor and Interfacing in PDF only on Docsity!

Objective:

To implement LCD interfacing, and understanding the initialization and working of LCD.

LCD Interfacing:

LCD interfacing is the communication or the interaction between the microcontroller and

the LCD. In this project we are using HD44780 Hitachi chipset compatible LCD’s for

interfacing with ATmega16.

Equipment:

Components Quantity

Bread Boards 2

6 pins on/off switch 1

16MHz crystal oscillator 1

NPN SC1815 transistor 1

1μF Polarized capacitor 1

DB9 female plug 1

22pF non-polarized

capacitors

Connecting wires As required

green colored led 1

AT Mega 16 controller 1

Bread Boards 2

10kΩ resistor 1

100kΩ resistor 1

1kΩ resistor 1

Circuit:

Implementation:

There are two modules for LCD interfacing. The hardware and the coding for LCD in VMlab.

Hardware:

To implement the hardware module, we are using ATmega16 microcontroller. The chip is

connected to a DB9 plug (female connector) for ISP connection as shown in the circuit. This

ISP connection is used for serial communication with the PC to burn the program in the

chip. There is a reset circuitry to reset the microcontroller.

Coding:

The coding to initialize the LCD in 8-bit mode and display a string is done in VMlab using

the following steps:

.STORE 250m ; Trace (micro+signals) storage time

D1 VDD PA

led.c:

#include

#include

#include

#include

int main(void)

while(1)

DDRA = 1;

PORTA = 0;

_delay_ms(250);

PORTA =1;

_delay_ms(250);

LCD code:

To Implement the LCD the steps mentioned in the coding section are followed, i.e. the

values in the data register are altered according to the steps. The data is sent to the LCD

from PORTA as shown in the circuit diagram. PD4, PD5, and PD6 are used as RW, RS and E

signals respectively.

We are using three functions to implement the code.

op_char:

This module is used to send the data between the rise and fall of the enable signal as

shown in the following diagram:

The minimum time required to transfer the data is 450 nsec, however to make our program

failsafe, we are using a delay of 5ms. ‘value’ contains the data sent from PORTA.

void op_char (char value) { PORTD = 0x40; // only E is high PORTA = value; PORTD = 0x00; // E is low _delay_ms(DELAY); } initiallize:

This function is used to initialize the LCD by following the above mentioned steps. The bits

mentioned here are shown in the Table 2 of Appendix.

To set Interface length:

o DL - Set Data Interface Length : 8(1) (for 8-bt mode) o N - Number of Display Lines : 2(1) (for 2-lines) o F - Character Font: 5x10(1)

// Part 2: op_char (0x08); // To turn off the display // Part 3: op_char (0x01); // To clear the display // Part 4: op_char (0x07); //Set cursor move direction // Part 5: op_char (0x0E); //TO enable display or cursor }

write:

This function is used to write a character on the LCD. Here we set RS=1 (which means

data) and data is sent between the rise and fall of E. The data here is the ASCII code of the

character stored in PORTA.

_void write (char value) { // To Write a character to the display PORTD = 0x60; // E and RS both are high PORTA = value; PORTD = 0x20; // E is low delay_us(DELAY); }

Code: final.prj: .MICRO "ATmega16"

.TOOLCHAIN "GCC" .GCCPATH "D:\WinAVR‐20080430"

.GCCMAKE AUTO .TARGET "final.hex" .SOURCE "final.c"

.TRACE ; Activate micro trace .POWER VDD=5 VSS=0 ; Power nodes

.CLOCK 1meg ; Micro clock .STORE 250m ; Trace (micro+signals) storage time

;X[inst_name] LCD(chars lines oscil_freq) RS RW E D7 D6 D5 D4 D3 D2 D1 D X1 LCD(16 2 250k) PD5 PD4 PD6 PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA

final.c: // *********************************************************** // Project: LCD Interfacing

// Author: Group # 9 // Module description: Implementing LCD interfacing using HD44780 type // ***********************************************************

define F_CPU 16000000UL

#include

#include

op_char (0x80); // To Position the cursor back on 1st line in each loop while(text1[i] !='\0') { write (text1[i]); i++; } op_char(0xC0); // To move on to the next line

i = 0; while(text2[i] !='\0') { write (text2[i]); i++; } } } // ***********************************************************

// Functions Definitions //

// Initializing the LCD

// =========================================================== void initiallize (void)

{ //STEP 1 _delay_ms(16); // to give delay of more than 15msec (roughly)

//STEP 2

op_char (0x30); //STEP 3 op_char (0x30); //STEP 4 op_char (0x30); //STEP 5 // Part 1: op_char(0x3C); // To set interface length // Part 2: op_char (0x08); // To turn off the display // Part 3: op_char (0x01); // To clear the display // Part 4: op_char (0x07); //Set cursor move direction // Part 5: op_char (0x0E); //To enable display or cursor }

// Operating Characteristics

// =========================================================== void op_char (char value)

{ PORTD = 0x40; // only E is high PORTA = value;