Hi, I am unable to initialise this 16x2 LCD Display, could any one here help please? Went through past threads and still unable to solve
Using a PIC18F4520 with 4Mhz crystal
First line is filled with black boxes, second line is clear
Code:
#include <p18f4520.h>
#include <delays.h>
#include <timers.h>
#include <stdio.h>
#pragma config WDT = OFF // Disable Watchdog timer
#pragma config BOREN = OFF // Disable Brown-out reset
#pragma config LVP = OFF // Disable low voltage ICSP
#define LCD_DATA PORTD // LCD Data
#define LCD_RS PORTBbits.RB4 // RS signal for LCD
#define LCD_E PORTBbits.RB3 // E signal for LCD
void Init_LCD(void); // Initialize the LCD
void W_ctr_8bit(char); // 8-bit Control word for LCD
void W_data_8bit(char); // 8-bit Text Data for LCD
void Delay_1kcyc(void); // 1000 cycles delay, 1ms
void main()
{
unsigned char i=0; //loop variable
char MESS[12] ="WELCOME!!!";
ADCON1=0x0F; // Ports A,B & E as digital I/O
TRISA=0x00;
TRISB=0; // RB3,RB4 for LCD interface RS&E
TRISD=0; // Port D as LCD Data Output
TRISE=0x00;
Delay10KTCYx(1);
Init_LCD(); // Init LCD 8-bit interface,multiple line
W_ctr_8bit(0b11000000);
for(i=0;i<10;i++)
{
Delay1KTCYx(1); //small delay
W_data_8bit(MESS[i]); // Write individual character to LCD
}
}
/* LCD display initialization */
void Init_LCD(){
W_ctr_8bit(0b00111000); // Function Set - 8-bit, 2 lines, 5X7
W_ctr_8bit(0b00001100); // Display on, cursor on
W_ctr_8bit(0b00000110); // Entry mode - inc addr, no shift
W_ctr_8bit(0b00000001); // Clear display
W_ctr_8bit(0b00000110); // Return cursor to home position
}
/* Write control word to LCD */
void W_ctr_8bit(char x){
LCD_RS = 0; // Logic ‘0’
Delay1KTCYx(1); //small delay
LCD_E = 1; // Logic ‘1’
Delay1KTCYx(1); //small delay
LCD_DATA = x;
Delay1KTCYx(1); //small delay
LCD_E = 0; // Logic 0’
Delay1KTCYx(1); // delay
}
/* Write text data to LCD */
void W_data_8bit(char x){
LCD_RS = 1; // Logic ‘1’
Delay1KTCYx(1); //small delay
LCD_E = 1; // Logic ‘1’
Delay10KTCYx(1); //small delay
LCD_DATA = x;
Delay1KTCYx(1); //small delay
LCD_E = 0; // Logic ‘0’
Delay10KTCYx(25); // delay
}
Help please, I tried for really long already.