#include <16F877a.H>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay (clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#use i2c(MASTER, FAST, SCL=PIN_C3, SDA=PIN_C4, FORCE_HW)
#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3
#include <24256.c>
#define rs PIN_C0
#define rw PIN_C1
#define en PIN_C2
void lcdcmd(unsigned char cmd);
void lcddata(unsigned long int volt);
char const line1[]= {"Hello World"};
//=================================
void main()
{
int8 i;
int buffer[17];
set_tris_b(0x00);
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x80);
//while(1)
// Write "Hello World" to external eeprom chip.
for(i = 0; i < sizeof(line1); i++)
write_ext_eeprom(i, line1[i]);
// Read characters from the external eeprom chip
// and write them into a RAM buffer.
for(i = 0; i < sizeof(line1); i++)
buffer[i] = read_ext_eeprom(i);
//bufferr = buffer[i];
lcddata(buffer[i]);
// Display the message on the LCD.
//printf(lcd_putc, buffer);
while(1);
}
void lcdcmd(unsigned char cmd)
{
output_b(cmd);
output_low(rs);
output_low(rw);
output_high(en);
delay_ms(1);
output_low(en);
}
void lcddata(unsigned long int volt)
{
output_b(volt);
output_high(rs);
output_low(rw);
output_high(en);
delay_ms(1);
output_low(en);
}