Aqui esta la libreria que modificamos el amigo Duende_azul y pues yo

BAsados en la bien conocidad flex_lcd para trabajar el lcd2x16 con ayuda de un registro de corrimiento con solo 3 pines del microcontrolador.
Como observan en el diagrama la pantalla se programa en modo 4 bits.
Los pines utilizados son :
LCD_E Señal de control Enable de la pantalla.
LCD_CK Señal de reloj del registro de corrimiento.
LCD_DAT Salida del bit menos significativo hacia el registro de corrimiento.
Adjunto archivo *.ZIP
-Códigi fuente
-Libreria
-Diagrama de electrónico
-Simulación en proteus 7.2 sp2
- Aquí la libreria -// flex_lcd_3_pins.c
//Modificación de Flex_lcd por Duende_Azul y Akenafab
//Trabaja con 3 pines y 74VHC164
//8-Bit Serial-In, Parallel-Out Shift Register
//La LCD se usa en modo 4bits
//Revisar diagrama de conexion Adjunto
//Se ha utilizado a una velocidad de @40MHz sin ningun problema
//No esta habilitada la lectura del LCD
//RW debe ir a gnd
//Definir pines antes de llamar libreria//
//#define LCD_E PIN_A0
//#define LCD_CK PIN_A1
//#define LCD_DAT PIN_A2
//========================================
int RS_bit;
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the 2nd line
int8 const LCD_INIT_STRING[4] =
{
0x20 | (lcd_type << 2), // Func set: 4-bit, 2 lines, 5x8 dots
0xc, // Display on
1, // Clear display
6 // Increment cursor
};
//-------------------------------------
void lcd_send_nibble(int8 nibble, int rs_bit)
{
int x;
if(RS_bit==1)
nibble=nibble|0x10;
for(x=0;x<5;x++){
output_bit(LCD_DAT,shift_right(&nibble,1,0));
delay_cycles(1);
output_low(LCD_CK);
delay_us(1);
output_high(LCD_CK);}
output_high(LCD_E);
delay_us(2);
output_low(LCD_E);
}
//-----------------------------------
//----------------------------------------
// Send a byte to the LCD.
void lcd_send_byte(int8 address, int8 n)
{
//output_low(LCD_RS);
RS_bit=0;
delay_us(100);
if(address)
//output_high(LCD_RS);
RS_bit=1;
else
//output_low(LCD_RS);
RS_bit=0;
delay_cycles(1);
output_low(LCD_E);
lcd_send_nibble(n >> 4,RS_bit);
lcd_send_nibble(n & 0xf,RS_bit);
}
//----------------------------
void lcd_init(void)
{
int8 i;
//output_low(LCD_RS);
RS_bit=0;
output_low(LCD_E);
delay_ms(20);
for(i=0 ;i < 3; i++)
{
lcd_send_nibble(0x03,RS_bit);
delay_ms(5);
}
lcd_send_nibble(0x02,RS_bit);
for(i=0; i < sizeof(LCD_INIT_STRING); i++)
{
lcd_send_byte(0, LCD_INIT_STRING[i]);
delay_ms(5);
}
}
//----------------------------
void lcd_gotoxy(int8 x, int8 y)
{
int8 address;
if(y != 1)
address = lcd_line_two;
else
address=0;
address += x-1;
lcd_send_byte(0, 0x80 | address);
}
//-----------------------------
void lcd_putc(char c)
{
switch(c)
{
case '\f': //limpia pantalla
lcd_send_byte(0,1);
delay_ms(8);
break;
case '\n': //cambio de linea
lcd_gotoxy(1,2);
break;
case '\b': //retrocede 1 caracter
lcd_send_byte(0,0x10);
break;
default:
lcd_send_byte(1,c);
break;
}
}
//------------------------------
void lcd_setcursor_vb(short visible, short blink) {
lcd_send_byte(0, 0xC|(visible<<1)|blink);
}
- Ejemplo -/* http://www.todopic.com.ar/foros/ */
#include <16F88.h>
#FUSES INTRC_IO,NOWDT,PUT,MCLR,NOBROWNOUT,NOLVP,NOPROTECT,NODEBUG,CCPB0,NOFCMEN,NOIESO
#use delay(Internal=8M)
//------------ Pines del LCD ---------------------//
#define LCD_E PIN_A0
#define LCD_CK PIN_A1
#define LCD_DAT PIN_A2
//--------------------------------------------------//
#include "flex_lcd_3pins.c" // Cargamos libreria del lcd
void main(){
delay_ms(100);
output_a(0);
output_b(0);
lcd_init(); // inicializamos el LCD
lcd_setcursor_vb(1,1); //cursor visible,papadeo
while(1){
printf(lcd_putc,"\f-LCD 3 pin Mode-\n* !.|.|..|.|.! *");
delay_ms(1000);
printf(lcd_putc,"\f* Duende_Azul *\n * Akenafab *");
delay_ms(1000);
}//end while
}//end main