Download V02 - EleSof
Transcript
USER
MANUAL
PICBox1
e EleSof
30
®
page
s
Lab:[5] Drive 16x2-LCD Display at 8-Bit mode
This example illustrates the use of an alphanumeric LCD display in 8- bit mode. 16x2 LCD data lines are
interface with Port ‘D’ & command lines with Port ‘E’. Figure below shows connection schematic.
VCC
10K
R9
VCC
VCC
0
Reset
10K
RSTbut/MCLR
C
100nF
SW1
VEE
LCD-RS
LCD-R/W
LCD-E
LCD-D0
LCD-D1
LCD-D2
LCD-D3
LCD-D4
LCD-D5
LCD-D6
LCD-D7
LED+
LED-
GND
VCC
JP2
LCD-RS
LCD-RW
LCD-E
GND
VCC
VO
RS
R/W
E
D0
D1
D2
D3
D4
D5
D6
D7
LED+
LED-
J4
20
C1
PIC16F87XA
R21
LCD GLCD
BACKLIGHT
R1
Top view
RD7/LCD-D7
RD6/LCD-D6
RD5/LCD-D5
RD4/LCD-D4
C2
RD0/LCD-D0
RD1/LCD-D1
RD3/LCD-D3
RD2/LCD-D2
This alphanumeric LCD can be driving in two modes 4-bit & 8-bit, here is an example code to display message
over LCD at 8-bit mode.
CODE:
/*
Drive 16x2- LCD Display at 8-Bit Mode
• Project name:
• Revision History: 1.0
• Description:
This is a simple program to drive 16x2 LCD at 8-Bit Mode
• Configuration:
MCU:
PIC16F8XX
Dev-Board: PICBox1
Oscillator: External 20 MHz
Compiler: CCS (Demo) for PIC
*/
#include <16f877A.h>
#use delay(oscillator=20000000)
void command(unsigned char);
void init_lcd();
void data(unsigned char);
// Define of micro which have used in circuit
// Compiler will set HS config bit (External 20MHz crystal used)
// LCD command function declare
// LCD initialized function declare
// LCD data function declare
void main()
{
set_tris_d(0x00);
// Set Port ‘D’ as output
set_tris_e(0x00);
// Set Port ‘E’ as output
init_lcd();
// LCD initialized function call
// Command for selecting first row, fourth column
command(0x84);
data('E');data('l');data('e');data('S');data('o');data('f');
// Data to write over LCD
// Command for selecting second row, fourth column
command(0xC4);
data('P');data('I');data('C');data('B');data('o');data('x');data('1'); // Data to write over LCD
// Endless Loop
while(1);
}