Hello,
I looked at the sample C code in the datasheet and converted it over to the pic I'm using, but cannot get the LCD to display anything. Here is my code:
I think its a hardware problem but am not sure. Any suggestions?
Thanks!
I looked at the sample C code in the datasheet and converted it over to the pic I'm using, but cannot get the LCD to display anything. Here is my code:
Code:
#include "F:\TESTLCD\TESTLCD.h"
#include <math.h>
#use delay(clock=4000000)
void DATA_W(unsigned char);
void DATA(unsigned char);
void COM_W(unsigned char);
#define CLR_CS Pin_A2
#define SET_CS Pin_A2
#define CLR_A0 Pin_A1
#define SET_A0 Pin_A1
#define CLR_RES Pin_A3
#define SET_RES Pin_A3
#define CLR_E Pin_E1
#define SET_E Pin_E1
volatile unsigned int row;
volatile unsigned int col;
volatile unsigned int i;
volatile unsigned char c;
void DATA(char data1)
{
output_d (data1);
}
void COM_W(unsigned char data1)
{
DATA(data1);
output_high (SET_A0);
output_low (CLR_CS);
output_high (SET_E);
output_low (CLR_E);
}
void DATA_W(unsigned char data1)
{
DATA(data1);
output_low (CLR_A0);
output_low (CLR_CS);
output_high (SET_E);
output_low (CLR_E);
}
void main()
{
double i;
char c;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(False);
//Idle control lines and reset the display
output_low (CLR_RES);
output_low (CLR_E);
output_low (CLR_A0);
output_high (SET_CS);
DATA(0x00);
delay_ms(1);
output_high (SET_RES);
delay_ms(100);
//Sets the LCD
COM_W(0x40);
DATA_W(0x30);
DATA_W(0x87);
DATA_W(0x07);
DATA_W(0x27);
DATA_W(0x42);
DATA_W(0xEF);
DATA_W(0x00);
delay_ms(100);
//SCROLLING ON LCD
COM_W(0x44);
DATA_W(0x00);
DATA_W(0x00);
DATA_W(0xEF);
DATA_W(0x60);
DATA_W(0x09);
DATA_W(0xEF);
DATA_W(0x00);
DATA_W(0x00);
DATA_W(0x00);
DATA_W(0x00);
//Horizontal Dot Screen
COM_W(0x5A);
DATA_W(0x00);
//Overlay
COM_W(0x5B);
DATA_W(0x01);
COM_W(0x58);
DATA_W(0x56);
//clear text layer and call position 1
c='A';
COM_W(0x46);
DATA_W(0x00);
DATA_W(0x00);
//Clear the loop
COM_W(0x42);
output_low (CLR_A0);
output_low (CLR_CS);
for(i=0;i<(0x28*30);i=i+1)
{
DATA(0x20);
output_high (SET_E);
output_low (CLR_E);
}
output_high (SET_CS);
//end clear text layer
//clear layer 2
COM_W(0x46);
DATA_W(0x60);
DATA_W(0x09);
//Clear loop
COM_W(0x42);
output_low (CLR_A0);
output_low (CLR_CS);
for(i=0; i<((0x28)*240);i=i+1) //240*APL
{
DATA(0x00);
output_high (SET_E);
output_low (CLR_E);
}
output_high (SET_CS);
//end clear layer 2
//chip select read and write
COM_W(0x46);
DATA_W(0x00);
DATA_W(0x00);
//CSRFORM
COM_W(0x5D);
DATA_W(0x04);
DATA_W(0x86);
COM_W(0x59);//DISPLAY ON
COM_W(0x4C);//cursor direction shift to the right
COM_W(0x42);
DATA_W(0x20);//""
DATA_W(0x45);//E
DATA_W(0x50);//P
DATA_W(0x53);//S
DATA_W(0x4F);//O
DATA_W(0x4E);//N
while(1)
{
}
}
Thanks!
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.