Sunteți pe pagina 1din 6

3-Wire LCD driver for CCS PIC C compiler http://ccspicc.blogspot.com/2016/08/3-wire-lcd-driver-ccs-pic-c-74hc59...

Ver esta página en: Español Traducir Desactivar para: Inglés Opciones ▼

PIC Microcontroller Projects


Electronic projects using Microchip PIC® microcontrollers for hobbyists and students with C codes and simu

Home PIC18F4550 Projects PIC16F887 Projects PIC16F877A Projects PIC16F84A Projects PIC12F1822 Proje

Remote Control Projects Motor Control Projects

Seleccionar idi

Search This Blo

7-Segment

74HC595

ADC (27)

BLDC Motor

DAC (1)
3-Wire LCD driver for CCS PIC C compiler DC motor

DHT11(RHT01)
3-Wire LCD using shift register (for HD44780 compliant controllers)
DHT22(AM2302-RH
Generally the LCD display needs at least 6 data lines to operate. But there are some microcontrollers don't
have this number of available pins like the PIC12F family, which means that we have to find a solution to DS1307 RTC
decrease the number of pins used by the LCD display. DS3231 RTC
The idea is sending data serially to the LCD display via shift register, this shift register is serial-in parallel-out
which receives serial data from the microcontroller via two pins data pin and clock pin. HC-SR04

Any serial-in parallel out shift register can be used for example: 74HC595, 74HC164, CD4094 (HEF4094)... Interrupt
Circuit schematics are below.
L293D (17)
3-Wire LCD driver CCS C source code:
This is the full C code of the driver. LCD (48)
This driver tested with 1602 (16x2) LCD and 2004 (20x4) with crystal frequencies 8MHz and 48MHz.
LED (21)

// 3-Wire LCD driver for CCS PIC C compiler (for HD44780 compliant controllers) LM335 (4)
// http://ccspicc.blogspot.com/
LM35 (4)
// electronnote@gmail.com
MMC/SD Card
#define LCD_FIRST_ROW 0x80
PIC Projects
#define LCD_SECOND_ROW 0xC0

1 de 6 21/09/2017 11:59 p.m.


3-Wire LCD driver for CCS PIC C compiler http://ccspicc.blogspot.com/2016/08/3-wire-lcd-driver-ccs-pic-c-74hc59...

#define LCD_FOURTH_ROW 0xD4 PWM (21)


#define LCD_CLEAR 0x01
Remote control
#define LCD_RETURN_HOME 0x02
#define LCD_CURSOR_OFF 0x0C RF 315MHz-433MH
#define LCD_UNDERLINE_ON 0x0E
RTOS (1)
#define LCD_BLINK_CURSOR_ON 0x0F
#define LCD_MOVE_CURSOR_LEFT 0x10 ST7735 TFT
#define LCD_MOVE_CURSOR_RIGHT 0x14
Stepper Motor
#define LCD_TURN_ON 0x0C
#define LCD_TURN_OFF 0x08 UART (12)
#define LCD_SHIFT_LEFT 0x18 ULN2003
#define LCD_SHIFT_RIGHT 0x1E
USB (2)

short RS;
void lcd_write_nibble(unsigned int8 n){ Blog Archive
unsigned int8 i;
September
output_low(LCD_CLOCK_PIN);
output_low(LCD_EN_PIN); August (18)
for( i = 8; i > 0; i = i >> 1){
July (12)
if(n & i)
output_high(LCD_DATA_PIN); June (2)
else November
output_low(LCD_DATA_PIN);
October (11)
Delay_us(10);
output_high(LCD_clock_PIN); September
Delay_us(10);
August (6)
output_low(LCD_clock_PIN);
} July (10)
if(RS)
June (1)
output_high(LCD_DATA_PIN);
else May (24)
output_low(LCD_DATA_PIN); April (3)
for(i = 0; i < 2; i++){
Delay_us(10); March (31)

output_high(LCD_clock_PIN); February
Delay_us(10);
output_low(LCD_clock_PIN);
Popular Posts
}
output_high(LCD_EN_PIN); PIC16F877A Proje
delay_us(2);
PIC16F877A ADC
output_low(LCD_EN_PIN); C compiler

PIC18F4550 PWM
PIC C
void LCD_Cmd(unsigned int8 Command){
RS = 0; PIC16F877A PWM
C compiler
lcd_write_nibble(Command >> 4);
lcd_write_nibble(Command & 0x0F); DC motor control w
L293D (Proteus sim
if((Command == 0x0C) || (Command == 0x01) || (Command == 0x0E) || (Command == 0x0F)
|| (Command == 0x10) || (Command == 0x1E) || (Command == 0x18) || (Command == 0x08)
|| (Command == 0x14) || (Command == 0x02)) Facebook Page:
Delay_ms(50);

2 de 6 21/09/2017 11:59 p.m.


3-Wire LCD driver for CCS PIC C compiler http://ccspicc.blogspot.com/2016/08/3-wire-lcd-driver-ccs-pic-c-74hc59...

void LCD_GOTO(unsigned int8 col, unsigned int8 row){


switch(row){
case 1:
LCD_Cmd(0x80 + col-1);
break;
case 2:
LCD_Cmd(0xC0 + col-1);
Be the first of your f
break;
case 3:
LCD_Cmd(0x94 + col-1);
break;
case 4:
LCD_Cmd(0xD4 + col-1); Google+ Follow
break;
Electron Note
}

void LCD_Out(unsigned int8 LCD_Char){


RS = 1;
lcd_write_nibble(LCD_Char >> 4);
delay_us(10);
lcd_write_nibble(LCD_Char & 0x0F);break;

void LCD_Initialize(){
RS = 0;
362 have me in circle
output_low(LCD_DATA_PIN);
output_low(LCD_CLOCK_PIN);
output_low(LCD_EN_PIN);
output_drive(LCD_DATA_PIN);
output_drive(LCD_CLOCK_PIN);
output_drive(LCD_EN_PIN);
delay_ms(40);
lcd_Cmd(3);
delay_ms(5);
lcd_Cmd(3);
delay_ms(5);
lcd_Cmd(3);
delay_ms(5);
lcd_Cmd(2);
delay_ms(5);
lcd_Cmd(0x28);
delay_ms(50);
lcd_Cmd(0x0C);
delay_ms(50);
lcd_Cmd(0x06);
delay_ms(50);
lcd_Cmd(0x0C);
delay_ms(50);

3 de 6 21/09/2017 11:59 p.m.


3-Wire LCD driver for CCS PIC C compiler http://ccspicc.blogspot.com/2016/08/3-wire-lcd-driver-ccs-pic-c-74hc59...

3-Wire LCD driver

It is easy to add this file to your project just put it in your project folder or in the CCS PIC C driver folder.
As any file driver the 3-wire LCD driver must be included using the following line:
#include <3WireLCD.c>
3-Wire LCD CCS C driver routines:
When the 3-wire Lcd driver is used, the following variables must be declared as in this example where the
data line mapped at RB0,the clock line at RB1 and the enable line at RB2:
#define LCD_DATA_PIN PIN_B0
#define LCD_CLOCK_PIN PIN_B1
#define LCD_EN_PIN PIN_B2
The driver routines are described below:
LCD_Initialize(); // Must be called before any other function.
LCD_GOTO(unsigned int8 col, unsigned int8 row); // Set write position on LCD (upper left is 1,1 and second
row first position is 1,2)
LCD_Out(unsigned int8 LCD_Char); // Display Char on the LCD.
LCD_Cmd(unsigned int8 Command); // Send a command to the LCD
The following commands can be used with LCD_Com() (example: LCD_Com(LCD_CLEAR);)
LCD_FIRST_ROW Move cursor to the 1st row
LCD_SECOND_ROW Move cursor to the 2nd row
LCD_THIRD_ROW Move cursor to the 3rd row
LCD_FOURTH_ROW Move cursor to the 4th row
LCD_CLEAR Clear display
LCD_RETURN_HOME Return cursor to home position, returns a shifted display to
its original position. Display data RAM is unaffected.
LCD_CURSOR_OFF Turn off cursor
LCD_UNDERLINE_ON Underline cursor on
LCD_BLINK_CURSOR_ON Blink cursor on
LCD_MOVE_CURSOR_LEFT Move cursor left without changing display data RAM
LCD_MOVE_CURSOR_RIGHT Move cursor right without changing display data RAM
LCD_TURN_ON Turn Lcd display on
LCD_TURN_OFF Turn Lcd display off
LCD_SHIFT_LEFT Shift display left without changing display data RAM
LCD_SHIFT_RIGHT Shift display right without changing display data RAM
3-Wire LCD circuit schematic:
The hardware circuit is simple all what we need is a shift register (74HC595, 74HC164, CD4094).
3-Wire LCD using 74HC595 shift register:
The following circuit schematic shows the connection circuit between the LCD, 74HC595 and the
microcontroller.

4 de 6 21/09/2017 11:59 p.m.


3-Wire LCD driver for CCS PIC C compiler http://ccspicc.blogspot.com/2016/08/3-wire-lcd-driver-ccs-pic-c-74hc59...

3-Wire LCD using 74HC164 shift register:


The following circuit schematic shows 3-wire LCD connection using 74HC164 shift register.

3-Wire LCD using 74HC4094 (HEF4094, CD4094) shift register:


The following circuit for LCD display connection with HEF4094 shift register.

5 de 6 21/09/2017 11:59 p.m.


3-Wire LCD driver for CCS PIC C compiler http://ccspicc.blogspot.com/2016/08/3-wire-lcd-driver-ccs-pic-c-74hc59...

Example:
The following URL shows how to interface PIC16F877A microcontroller with 3-wire LCD.
Interfacing PIC16F877A with 3-wire LCD

Posted by Electron Note at 8/30/2016 02:24:00 PM

Labels: 74HC595 LCD

Newer Post Home Older Post

Powered by Blogger.

6 de 6 21/09/2017 11:59 p.m.

S-ar putea să vă placă și