meche
Junior Member level 2
This is my first time of interfacing an LCD module to a pic mcu (pic16f877a) but so far my code(I actually got it from the internet) doesn't work when I simulate it in proteus. My LCD is connected to port B. Below is my main c code for writing to the LCD.
And below is my config file (newxc8_header.h) for the project.
I compiles in MPLAB X IDE with XC8 compiler. I simulated in proteus. The LCD lights up but no message is displayed.
Please can someone help me out. I want to start using LCD for my projects but I am finding it very difficult.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #define _XTAL_FREQ 8000000 #include"newxc8_header.h" #include"Lcd_hd44780_pic16.h" #define RS RB5 #define EN RB4 #define D4 RB0 #define D5 RB1 #define D6 RB2 #define D7 RB3 void main (void) { TRISB=0x00; //Initialize the LCD Module LCDInit(LS_NONE); //Clear the display LCDClear(); LCDGotoXY(0x00); //Write a string LCDWriteString("Hello World !"); while(1) { //Do nothing, just loop indefinitely } }
And below is my config file (newxc8_header.h) for the project.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [/ PIC16F877A Configuration Bit Settings // 'C' source line config statements // CONFIG #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) // #pragma config statements should precede project file includes. // Use project enums instead of #define for ON and OFF. #include <xc.h>]
I compiles in MPLAB X IDE with XC8 compiler. I simulated in proteus. The LCD lights up but no message is displayed.
Please can someone help me out. I want to start using LCD for my projects but I am finding it very difficult.
Last edited by a moderator: