hi,
I am practicing sending the data to LCD using four pins.I am not able to get the output.Please help me.
This is my code
#include<18f452.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT
#use delay(clock=4000000)
#define rs PIN_C0
#define rw PIN_C1
#define en PIN_C2
//data pins D0,D1,D2,D3
void lcd_command(int8 command)
{
int8 temp;
temp=(command>>4) & 0x0f; //mask lower nibble
output_d(temp); //send higher nibble
delay_ms(5);
output_low(rs);
output_high(en);
delay_cycles(2);
output_low(en);
output_d(0x00);
temp=command & 0x0f; //mask higher nibble
output_d(temp); //send lower nibble
delay_ms(5);
output_low(rs);
output_high(en);
delay_cycles(2);
output_low(en);
output_d(0x00);
delay_ms(10);
delay_ms(250);
}
void lcd_data(int8 data)
{
int8 temp;
temp=(data>>4) & 0x0f; //mask lower nibble
output_d(temp); //send higher nibble
delay_ms(5);
output_high(rs);
output_high(en);
delay_cycles(1);
output_low(en);
output_d(0x00);
temp=data & 0x0f; //mask higher nibble
output_d(temp); //send lower nibble
delay_ms(5);
output_high(rs);
output_high(en);
delay_cycles(1);
output_low(en);
output_d(0x00);
delay_ms(10);
delay_ms(250);
}
void main()
{
set_tris_d(0xf0);
set_tris_c(0);
while(1)
{
lcd_command(0x28);
lcd_command(0x0e);
lcd_command(0x06);
lcd_command(0x80);
lcd_data('a');
lcd_data('b');
lcd_data('c');
lcd_data('d');
}
}
Thank you.