tamil_yes
Junior Member level 1
lcd interfacing with pic16f877a
Hi to everyone
I am trying to display the character in LCD
I have interfaced the LCD with PIC 16f877A
follwing connection
LCD PIC
pin4 (RS) RB1
pin5 (RW) RE1
pin6(EN ) RE2
pin7 to pin14 PORTD
and i have connected contrst also
I am using CCS compiler
following program is compiling in CCS compiler
but not displaying anything
can any one help me
coding
#include <16F877A.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#byte LCD_data=0x08
#bit LCD_D7=0x08.7
#bit LCD_RS=0x06.1
#bit LCD_RW=0x09.1
#bit LCD_EN=0x09.2
void LCD_busy()
{
LCD_D7=1;
LCD_EN=1;
LCD_RS=0;
LCD_RW=1;
while(LCD_D7)
{
LCD_EN=0;
LCD_EN=1;
}
}
void LCD_init()
{
LCD_data=0x38; // funtion set ; 2 line,8-bit,5x7 dot
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
LCD_data=0x0F; // display on,cursor blink
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
LCD_data=0x01; // clear lcd
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
LCD_data=0x06; // entry mode set,auto increment with no. shift
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
}
void LCD_command(unsigned char var)
{
LCD_data=var;
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
}
void LCD_senddata(unsigned char var)
{
LCD_data=var;
LCD_RS=1;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,WDT_18MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
LCD_init();
//LCD_command();
LCD_senddata('P');
}
Hi to everyone
I am trying to display the character in LCD
I have interfaced the LCD with PIC 16f877A
follwing connection
LCD PIC
pin4 (RS) RB1
pin5 (RW) RE1
pin6(EN ) RE2
pin7 to pin14 PORTD
and i have connected contrst also
I am using CCS compiler
following program is compiling in CCS compiler
but not displaying anything
can any one help me
coding
#include <16F877A.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#byte LCD_data=0x08
#bit LCD_D7=0x08.7
#bit LCD_RS=0x06.1
#bit LCD_RW=0x09.1
#bit LCD_EN=0x09.2
void LCD_busy()
{
LCD_D7=1;
LCD_EN=1;
LCD_RS=0;
LCD_RW=1;
while(LCD_D7)
{
LCD_EN=0;
LCD_EN=1;
}
}
void LCD_init()
{
LCD_data=0x38; // funtion set ; 2 line,8-bit,5x7 dot
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
LCD_data=0x0F; // display on,cursor blink
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
LCD_data=0x01; // clear lcd
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
LCD_data=0x06; // entry mode set,auto increment with no. shift
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
}
void LCD_command(unsigned char var)
{
LCD_data=var;
LCD_RS=0;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
}
void LCD_senddata(unsigned char var)
{
LCD_data=var;
LCD_RS=1;
LCD_RW=0;
LCD_EN=1;
LCD_EN=0;
LCD_busy();
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,WDT_18MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
LCD_init();
//LCD_command();
LCD_senddata('P');
}