Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interface to LCD using CCS PCWH

Status
Not open for further replies.

SphinX

Advanced Member level 3
Joined
Jan 25, 2002
Messages
822
Helped
58
Reputation
116
Reaction score
29
Trophy points
1,308
Location
EGYPT
Activity points
7,045
ccs lcd

Hi,

For those who want to interface to LCDn C language using CCS
Ok.
All the LCD functions are ready built in the driver LCD.C file (you will find it in the drivers folder)

All you have to do is edit the LCD.C file
WHY?
Becuse it use the PORTD as a connections to LCD
But I use PIC16F84 and i want to connect the LCD to PORTB

So

-open the LCD.C file
- search for these two lines

// Un-comment the following define to use port B
// #define use_portb_lcd TRUE

edit them to

// Un-comment the following define to use port B
#define use_portb_lcd TRUE

- save the LCD.C file

The connections will be

PORTB LCD
RB0 enable
RB1 rs
RB2 rw
RB4 D4
RB5 D5
RB6 D6
RB7 D7

Now i will make simple program to write to LCD

#include <16F84.h>
#use delay(clock=4000000) // you must use this line becuse the LCD.C use the delay_us() functions

#include <lcd.c>

void main() {

lcd_init();
lcd_gotoxy(1,1);
lcd_putc("Welcome to EGYPT");

}

The proteus demo plus the c program in the attachment

Finally,

Here is the LCD functions you can use

lcd_init() Must be called before any other function.
lcd_putc(c) Will display c on the next position of the LCD.
The following have special meaning:

\f Clear display
\n Go to start of second line
\b Move back one position


lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1)
lcd_getc(x,y) Returns character at position x,y on LCD


Bye
 

lcd ccs

Hello SphinX

I have on experimented board with the next connections

LCD/\/PIC 16F877

DB7--> RB7
DB6--> RB6
DB5--> RB5
DB4--> RB4
E--> RB2
RS--> RB3
RW--> GROUND

How to modify the driver "lcd.c"
 

ccs lcd example

Salam,

Ok Change

(1)

// Un-comment the following define to use port B
// #define use_portb_lcd TRUE

to

// Un-comment the following define to use port B
#define use_portb_lcd TRUE



(2)

struct lcd_pin_map { // This structure is overlayed
BOOLEAN enable; // on to an I/O port to gain
BOOLEAN rs; // access to the LCD pins.
BOOLEAN rw; // The bits are allocated from
BOOLEAN unused; // low order up. ENABLE will
int data : 4; // be pin B0.
} lcd;

to

struct lcd_pin_map {
BOOLEAN unused1; // For RB0
BOOLEAN unused2; // For RB1
BOOLEAN enable; // For RB2
BOOLEAN rs; // For RB3
int data : 4; // For RB4-RB7
} lcd
;

(3)

comment any line contain 'rw.lcd' and don't forgot to connect rw to gnd in your circuit :)

Bye
 
lcd.c ccs

try an app called quickbuilder
for some fun
 

ccs c lcd

mayaka2004 said:
try an app called quickbuilder
for some fun

How to se CCS recornigze the Lower and upper case ?
such

int Index,index;

is different ?
 

ccs lcd.c

Hey,
I try to use your easy example but there is one problem with my lcd.c : I always get the error-message a #device required before this line in line 44(this is the line in which the struct lcd_pin_map { begin) when I want to compile. I did exactly the same u described.

have u an answer for the problem???
I have no idea anymore:|

thanks a lot
Anna
 
i have a problem if i simule the attachement of "SphinX"

some own can help me ? please
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top