SphinX
Advanced Member level 3
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
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