Hi all. I am a trainee electronics technician and I have been assigned to a project which involves interfacing a PIC18F6723 to a New Haven Display 0420DZ-FSW LCD Module. This display uses an SPLC780D-01 controller. I am using Port D on the pic for the data lines and RE5-7 for the control lines. The connections are correct and working fine.
The crystal for the PIC was initially 3.6864MHz but I have bumped it up to 14.7456MHz to get things done quicker. I have changed the configuration of the PIC to deal with the faster crystal and that is all working fine. The only problem introduced by increasing the crystal frequency is that my LCD library no longer works like it did. When I try to display a string of characters with it, only some of them are displayed. I have found that putting a 30µs delay in my Send_Character function fixes this issue, but this introduces a significant delay for each LCD line and the whole process is slower than it was with the slower crystal.
This is a really weird bug and it has me stumped. My signals look fine on the scope, well within their limits. I will post the library that I am using, if you have encountered this problem before or have some helpful thoughts on this then please feel free to reply.
The crystal for the PIC was initially 3.6864MHz but I have bumped it up to 14.7456MHz to get things done quicker. I have changed the configuration of the PIC to deal with the faster crystal and that is all working fine. The only problem introduced by increasing the crystal frequency is that my LCD library no longer works like it did. When I try to display a string of characters with it, only some of them are displayed. I have found that putting a 30µs delay in my Send_Character function fixes this issue, but this introduces a significant delay for each LCD line and the whole process is slower than it was with the slower crystal.
This is a really weird bug and it has me stumped. My signals look fine on the scope, well within their limits. I will post the library that I am using, if you have encountered this problem before or have some helpful thoughts on this then please feel free to reply.
Code:
#include <htc.h>
#include "lcd_8bit.h"
#include "delay.h"
void Send_Command(char command)
{
PORTD = command; //Assign command byte to Port D outputs,
LCD_RS = 0; //Send instructions.
LCD_RW = 0; //Write mode.
NOPLoop(20); //I need this delay for some reason.
LCD_EN = 1; //Send Enable pin hi.
delay_Us(5); //More than enough delay here.
LCD_EN = 0; //Trigger Enable (falling edge).
}
void Send_Character(char character)
{
PORTD = character; //Assign character to Port D.
LCD_RS = 1; //Send characters.
LCD_RW = 0; //Write mode.
delay_Us(30); //<<<Won't print characters properly without this.
LCD_EN = 1; //Send Enable pin hi.
delay_Us(5); //More than enough delay here.
LCD_EN = 0; //Trigger Enable (falling edge).
}
void lcd_Clear(void)
{
Send_Command(0x01); //(Clear screen)
delay_Ms(5);
}
void lcd_Print(const char * s)
{
while(*s)
{
Send_Character(*s++);
}
}
void lcd_Goto(unsigned char position)
{
Send_Command(0x80+position); //Set DDRAM Address in counter.
}
void lcd_Init()
{
LCD_EN = 0; //Ensure Enable pin is low.
delay_Ms(20); //Delay of 15ms.
Send_Command(0x30); //Wake up.
delay_Ms(5); //Delay of 5ms.
Send_Command(0x30); //Wake up #2.
delay_Us(160); //Delay of 160us.
Send_Command(0x30); //Wake up #3.
delay_Us(160); //Delay of 160us.
Send_Command(0x38); //Function set: 8-bit, 2-line, 5 X 8 font.
Send_Command(0x10);
Send_Command(0x0F); //Display on, no cursor or blink.
Send_Command(0x06); //Entry mode set.
}