//This is LCD_Example.c File
#include <Lcd_Example.h>
#define ENABLE_PIN C2
#define RS_PIN C0
#define RW_PIN C1
#define Data4 B4
#define Data5 B5
#define Data6 B6
#define Data7 B7
#include <lcd.c>
void main()
{
set_tris_b(0x00);
set_tris_c(0x00);
Delay_ms(100);
lcd_init();
Delay_ms(100);
lcd_gotoxy(1,1);
lcd_putc("\fReady...\n");
while(1);
}
/*****************************************/
//This is LCD_Example.h file
#include <16F877A.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#use delay(clock=20000000)
I am not using MPLAB IDE to write my code..
I am using PIC C IDE(PCW) to write my code..
First of all if you are just writing to LCD, and not reading anything then it is better to simply connect the R/W pin of LCD to ground.
Try this and then post the result, meanwhile i'll have a look at the code
//// Example of pin access: ////
//// #define LCD_ENABLE_PIN PIN_E0 ////
//// #define LCD_RS_PIN PIN_E1 ////
//// #define LCD_RW_PIN PIN_E2 ////
//// #define LCD_DATA4 PIN_D4 ////
//// #define LCD_DATA5 PIN_D5 ////
//// #define LCD_DATA6 PIN_D6 ////
//// #define LCD_DATA7 PIN_D7 ////
#define ENABLE_PIN C2
#define RS_PIN C0
#define RW_PIN C1
#define Data4 B4
#define Data5 B5
#define Data6 B6
#define Data7 B7
#include <Lcd_Example.h>
#define LCD_RS_PIN PIN_C0
#define LCD_RW_PIN PIN_C1
#define LCD_ENABLE_PIN PIN_C2
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
#include <lcd.c>
void main()
{
set_tris_b(0x00);
//output_b(0x00);
set_tris_c(0x00);
//output_c(0x00);
lcd_init();
Delay_ms(1000);
while(1)
{
lcd_gotoxy(1,1);
while(1);
Delay_ms(1000);
lcd_putc("\fReady...\n");
Delay_ms(1000);
}
}
Did you use the automatic project code generator to make that test code for the LCD? If so, it does not work; the CCS compiler uses the wrong defines! The exact same thing happened to me when I made my first LCD test program. This is what to do...
Open the LCD.C header file from the Drivers folder under installation (mine is here: C:\Program Files (x86)\PICC\Drivers). You don't need to change anything there, I'm just showing you where to find the information.
Look in the header information, it will show how to define the pin names for the LCD.
It looks like this:
Code:
//// Example of pin access: ////
//// #define LCD_ENABLE_PIN PIN_E0 ////
//// #define LCD_RS_PIN PIN_E1 ////
//// #define LCD_RW_PIN PIN_E2 ////
//// #define LCD_DATA4 PIN_D4 ////
//// #define LCD_DATA5 PIN_D5 ////
//// #define LCD_DATA6 PIN_D6 ////
//// #define LCD_DATA7 PIN_D7 ////
Note that the LCD data pins are defined as LCD_DATA4 etc. You can change the pins you use, but the defined name must be like the above. The example code that is generated by project wizard uses the wrong defined names - DATA4 is wrong - it should be LCD_DATA4 etc.
Change your defines to be like the above and try again.
First of all if you are just writing to LCD, and not reading anything then it is better to simply connect the R/W pin of LCD to ground.
#include <Lcd_Example.h>
#define LCD_RS_PIN PIN_C0
#define LCD_RW_PIN PIN_C1
#define LCD_ENABLE_PIN PIN_C2
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
#include <lcd.c>
void main()
{
set_tris_b(0x00);
//output_b(0x00);
set_tris_c(0x00);
//output_c(0x00);
lcd_init();
Delay_ms(1000);
while(1)
{
lcd_gotoxy(1,1);
Delay_ms(1000);
lcd_putc("Arun Sharma");
Delay_ms(10000);
}
}
Your code looks OK apart from that - check your connections, LCD contrast connection, etc.
Placed VDD,VSS,VEEFoxyRick brings up a valid point, Proteus may expect you to make the Vdd,Vss and Vee connections.
BigDog
Two quick thoughts (I'm about to eat)...
Take out the set_tris lines, the compiler will do that for you in the background.
Do you have a main.h that should be included? CCS usually makes one.
Your code looks OK apart from that - check your connections, LCD contrast connection, etc.
//Lcd_Example.h
#include <16F877A.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#use delay(clock=20000000)
//and Lcd_Example.c is posted above
be sure to modify the flags in the LCD.C file for your particular LCD!
you have wrongly set RW,EN and RS in your code according to your proteus file.
#include <lcd.c>
you have wrongly set RW,EN and RS in your code according to your proteus file.
/*#include <Lcd_Example.h>
#define LCD_RS_PIN PIN_C0
#define LCD_RW_PIN PIN_C1
#define LCD_ENABLE_PIN PIN_C2
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
#include <lcd.c>
void main()
{
Delay_ms(100);
lcd_init();
Delay_ms(1000);
while(1)
{
lcd_gotoxy(1,1);
Delay_ms(1000);
lcd_putc("Arun Sharma");
Delay_ms(10000);
}
}*/
#include <lcd.c>
void main()
{
lcd_init();
lcd_gotoxy(1,1);
lcd_putc("Welcome to EGYPT");
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?