Jent CWH
Newbie level 6
Hi, I am new here. Hope can get help since i'm unable to interface the LCD with my PIC18F4550 by using CCS compiler. I'm not too familiar with the C programming, but i tried to write out a C code. Hope you guys can check and inform me any errors occured.
my connection for the LCD to the PIC18F4550:
RS----RB4
R/W--Gnd
E-----RB5
DB0 to DB7----RD0 to RD7
This is my code:
#include <18F4550.h>
#fuses NOLVP, NOWDT, XT
#use delay(clock=20M,crystal)
#include <lcd.c>
#define LCD_RS PIN_B4
#define LCD_E PIN_B5
void lcd_init(void);
void port_init(void);
void lcd_write(unsigned char c);
void lcd_goto(unsigned char c);
void port_init(void)
{
set_tris_d(0x00);
set_tris_b(0b00000011);
}
void lcd_init(byte)
{
lcd_write(0x38);
delay_ms(20);
lcd_write(0x01);
delay_ms(15);
lcd_write(0x06);
delay_ms(15);
lcd_write(0x0F);
delay_ms(15);
lcd_write(0x80);
delay_ms(15);
output_low(LCD_RS);
output_high(LCD_E);
delay_ms(20);
output_high(LCD_RS);
output_low(LCD_E);
}
void main()
{
printf(lcd_putc, "Hello");
lcd_gotoxy(1,2);
while(TRUE)
{
}
}
I'm able to compile, but my LCD existed with a full black boxes in first line. Can I know what the problems are? Thanks a lot..^.^
my connection for the LCD to the PIC18F4550:
RS----RB4
R/W--Gnd
E-----RB5
DB0 to DB7----RD0 to RD7
This is my code:
#include <18F4550.h>
#fuses NOLVP, NOWDT, XT
#use delay(clock=20M,crystal)
#include <lcd.c>
#define LCD_RS PIN_B4
#define LCD_E PIN_B5
void lcd_init(void);
void port_init(void);
void lcd_write(unsigned char c);
void lcd_goto(unsigned char c);
void port_init(void)
{
set_tris_d(0x00);
set_tris_b(0b00000011);
}
void lcd_init(byte)
{
lcd_write(0x38);
delay_ms(20);
lcd_write(0x01);
delay_ms(15);
lcd_write(0x06);
delay_ms(15);
lcd_write(0x0F);
delay_ms(15);
lcd_write(0x80);
delay_ms(15);
output_low(LCD_RS);
output_high(LCD_E);
delay_ms(20);
output_high(LCD_RS);
output_low(LCD_E);
}
void main()
{
printf(lcd_putc, "Hello");
lcd_gotoxy(1,2);
while(TRUE)
{
}
}
I'm able to compile, but my LCD existed with a full black boxes in first line. Can I know what the problems are? Thanks a lot..^.^