darkz10
Newbie level 1
#include <p18f4520.h>
#include <delays.h>
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
#define LCD_DATA PORTD
#define LCD_RS PORTBbits.RB1 // RS signal for LCD
#define LCD_E PORTBbits.RB2 // E signal for LCD
unsigned char LCD_TEMP,i,j,k,m;
char MESS[14]="Welcome to EPS";
char MESS1[9]="Thank you";
void main()
{
ADCON1=0x0F; // Set ports A,B & E as digital I/O
TRISB = 0b11111001; // RB1 & 2 for LCD interface RS & E
TRISD = 0;
// Port D as LCD data output
Init_LCD();
while(1)
{ // Init LCD 8-bit interface,multiple line
W_ctr_8bit(0b10000000);
for (i=0; i<14; i++) // Output message "WELCOME" to LCD
W_data_8bit(MESS); // Write individual character to LCD
W_ctr_8bit(0b11000000); // Write individual character to LCD
for (i=0; i<9; i++)
W_data_8bit(MESS1);
}
}
/* 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(0b00000010); // Return cursor to home position
}
/* Write control word to LCD */
void W_ctr_8bit(char x){
LCD_RS = 0; // Logic ‘0’
LCD_E = 1; // Logic ‘1’
LCD_DATA = x;
LCD_E = 0; // Logic 0’
Delay10TCYx(50); // 1ms delay
}
/* Write text data to LCD */
void W_data_8bit(char x){
LCD_RS = 1; // Logic ‘1’
LCD_E = 1; // Logic ‘1’
LCD_DATA = x;
LCD_E = 0; // Logic ‘0’
Delay10TCYx(50); // 1ms delay
}
#include <delays.h>
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
#define LCD_DATA PORTD
#define LCD_RS PORTBbits.RB1 // RS signal for LCD
#define LCD_E PORTBbits.RB2 // E signal for LCD
unsigned char LCD_TEMP,i,j,k,m;
char MESS[14]="Welcome to EPS";
char MESS1[9]="Thank you";
void main()
{
ADCON1=0x0F; // Set ports A,B & E as digital I/O
TRISB = 0b11111001; // RB1 & 2 for LCD interface RS & E
TRISD = 0;
// Port D as LCD data output
Init_LCD();
while(1)
{ // Init LCD 8-bit interface,multiple line
W_ctr_8bit(0b10000000);
for (i=0; i<14; i++) // Output message "WELCOME" to LCD
W_data_8bit(MESS); // Write individual character to LCD
W_ctr_8bit(0b11000000); // Write individual character to LCD
for (i=0; i<9; i++)
W_data_8bit(MESS1);
}
}
/* 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(0b00000010); // Return cursor to home position
}
/* Write control word to LCD */
void W_ctr_8bit(char x){
LCD_RS = 0; // Logic ‘0’
LCD_E = 1; // Logic ‘1’
LCD_DATA = x;
LCD_E = 0; // Logic 0’
Delay10TCYx(50); // 1ms delay
}
/* Write text data to LCD */
void W_data_8bit(char x){
LCD_RS = 1; // Logic ‘1’
LCD_E = 1; // Logic ‘1’
LCD_DATA = x;
LCD_E = 0; // Logic ‘0’
Delay10TCYx(50); // 1ms delay
}