Hi everybody,
I am trying to interface a PIC18F4520 to a standard 16x2 LCD with Hitachi HD44780 controller in 4-bit mode, I am using MPLAB IDE v2.35 with C18 compiler.
This is my code:
Attached you will find a screenshot of my schematic.
I am simulating it in ISIS with an XTAL of 20MHz, when I simulate the data pins for the LCD appear disconnected and the LCD is blank.
Can anyone spot the mistake?
Thanks in advanced for any help.
I am trying to interface a PIC18F4520 to a standard 16x2 LCD with Hitachi HD44780 controller in 4-bit mode, I am using MPLAB IDE v2.35 with C18 compiler.
This is my code:
Code:
/*Libraries*/
#include <stdio.h> //standard I/O library
#include <stdlib.h> //standard library
#include <xlcd.h> //LCD library
#include <delays.h> //Delays library
#include <p18f4520.h> //PIC18F4520 library
/*Fuses*/
#pragma config OSC = HS,FCMEN = OFF,IESO = OFF
#pragma config PWRT = ON,BOREN = OFF,BORV = 0
#pragma config WDT = OFF,WDTPS = 32768
#pragma config MCLRE = ON,LPT1OSC = OFF,PBADEN = OFF,CCP2MX = PORTC
#pragma config STVREN = OFF,LVP = OFF,XINST = OFF,DEBUG = OFF
#pragma config CP0 = OFF,CP1 = OFF,CP2 = OFF, CP3 = OFF
#pragma config CPB = OFF,CPD = OFF
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF
#pragma config WRTB = OFF,WRTC = ON,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF
#pragma config EBTRB = OFF
/*Delays for LCD - All calculated for Xtal=20MHz*/
void DelayFor18TCY(void)
{
Delay10TCYx(10); //Delay of at least 18 Clock Cycles
}
void DelayPORXLCD (void)
{
Delay1KTCYx(80); // Delay of at least 15ms
}
void DelayXLCD (void)
{
Delay1KTCYx(10); // Delay of at least 5ms
}
/*Main Program*/
void main (void){
ADCON1=0x0F; //All I/O as digital
OpenXLCD(FOUR_BIT & LINES_5X7); //Four bit mode and 5x7 lines
while(BusyXLCD());
WriteCmdXLCD(CURSOR_OFF & BLINK_OFF);
while (BusyXLCD()); //Wait for LCD
putrsXLCD("PIC18F4520"); //Output message to LCD
while(1){}; //Infinite loop
}
I am simulating it in ISIS with an XTAL of 20MHz, when I simulate the data pins for the LCD appear disconnected and the LCD is blank.
Can anyone spot the mistake?
Thanks in advanced for any help.
Attachments
-
44.2 KB Views: 29