#if defined(__PCH__)
#if defined use_portb_lcd
#byte lcd = 0xF81 // This puts the entire structure
#else
#byte lcd = 0xF82 // This puts the entire structure // AZICUETANO // DIRECCION DEL PURTOC 0xF82
#endif
#else
#if defined use_portb_lcd
#byte lcd = 6 // on to port B (at address 6) // AZICUETANO // DIRECCION DEL PURTOC 7 (ver datasheet pág. 117, ejemplo 10-3)
#else
#byte lcd = 7 // on to port D (at address 8)
#endif
#endif
#if defined use_portb_lcd
#define set_tris_lcd(x) set_tris_b(x)
#else
#define set_tris_lcd(x) set_tris_c(x)
#endif#include <18f2550.h>
#fuses xt,nowdt, nolvp,noprotect,NOPBADEN,NOMCLR,PUT
#use delay(clock=4000000)
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_RS PIN_B0
#define LCD_RW PIN_B1
#define LCD_E PIN_B2
#include <flex_lcd_2.c>
#use fast_io(b)
#use fast_io(a)
void main ()
{
port_b_pullups(true);
lcd_init();
lcd_putc("Hola...probando");
while(true);
}void lcd_init(void){
int8 i;
output_low(LCD_RS);
#ifdef USE_LCD_RW
output_low(LCD_RW);
#endif
output_low(LCD_E);
delay_ms(15);
for(i=0 ;i < 3; i++)
{
lcd_send_nibble(0x03);
delay_ms(5);
}
lcd_send_nibble(0x02);
for(i=0; i < sizeof(LCD_INIT_STRING); i++)
{
lcd_send_byte(0, LCD_INIT_STRING[i]);
// If the R/W signal is not used, then
// the busy bit can't be polled. One of
// the init commands takes longer than
// the hard-coded delay of 60 us, so in
// that case, lets just do a 5 ms delay
// after all four of them.
#ifndef USE_LCD_RW
delay_ms(5);
#endif
}
delay_ms(15);
}// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.
#define USE_LCD_RW 1