#include <16F628A.h>
#fuses INTRC_IO,NOPROTECT,NOBROWNOUT,NOMCLR,NOLVP,NOWDT,PUT // must include this line !!
#use fixed_io(A_OUTPUTS=40,41,42,43,44,46,47)
#define D7 PIN_A3
#define D6 PIN_A2
#define D5 PIN_A1
#define D4 PIN_A0
#define RS PIN_A4
#define RW PIN_A6
#define E PIN_A7
#byte port_A=5
Delay100()
{
delay_cycles(100);
}
Pulse_e()
{
output_high(E);
delay_cycles( 1 );
output_low(E);
}
LCD_Init()
{
OUTPUT_A(0x02); // 1st of Set 4 bit mode
Pulse_e();
OUTPUT_A(0x00); // 2nd of set 4 bit mode
Pulse_e();
delay_cycles( 5 );
OUTPUT_A(0x00); // 1st of turn on display
Pulse_e();
OUTPUT_A(0x0f); // 2nd of turn on display
Pulse_e();
delay_cycles( 5 );
OUTPUT_A(0x02); // 1st of 2 line mode
Pulse_e();
OUTPUT_A(0x08); // 2st of 2 line mode
Pulse_e();
delay_cycles(100);
}
main()
{
OUTPUT_A(0x00); //make sure all pins are at 0
Delay100();
LCD_Init();
OUTPUT_A(0x14); // send the first half of A with the RS pin high
Pulse_e();
OUTPUT_A(0x11); // send the second half of A with the RS pin high
Pulse_e();
delay_cycles(5);
}