Help me solve a problem with a PIC code for controlling GLCD

Status
Not open for further replies.

mostafa ewaiha

Newbie level 6
Joined
Sep 11, 2009
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
mansoura
Activity points
1,349
hi all

I'm in the graduation project and I've a problem with GLCD 128*64 based on KS108 by using PIC32MX360F256L --- MPLAB "C32"

every time I code PIC, the GLCD doesn't respond any signal


please, I need help

Added after 28 minutes:

Can someone suggest me example or where to study an application note.
 

Re: GLCD problem

Hello!

There are many reasons that may result in this.
- Are you sure the LCD works?
- Are you sure of your connections?
I would start by verify one by one.
For instance, use an oscilloscope, and issue a reset at the start of your
program, and verify that the reset in your software is actually connected
to the physical reset. Do the same with chip select, register select, etc…
- Are you sure of your SPI port setting? Put a scope on clock and data, and
send a byte which is easily identifyable (example 0x55 or 0xAA). Look at
the data ouput vs clock output.
- Are you sure of your initialization sequence?
Once the above works perfectly, verify your initialization sequence.
Try to change the contrast, try to change other parameters, for example bias,
etc… I would be surprised if you cannot make it work like this. But it's like
anything else, you have to put effort in it.

Dora.

 

Re: GLCD problem


You can use ISIS Proteus for debugging codes. It has model for this LCD module. We need see your codes for help.
 

Re: GLCD problem

Hi,

Refer this project. It is working. I tested it.
It has GLCD on Renesas microcontroller and written in C language.

**broken link removed**

You could port it to a PIC with some modifications.
 

Re: GLCD problem

thanks all

my code :

Code:
#include <p32xxxx.h>
#include <plib.h>
#include <explore.h>

#define LCD_TRIS 	TRISD
#define LCD_DATA 	PORTD
#define ENABLE 		PORTBbits.RB6
#define RW 			PORTBbits.RB5
#define DI 			PORTBbits.RB4
#define RESET 		PORTBbits.RB7

#define CS1		 	PORTBbits.RB2

#define CS2 		PORTBbits.RB3


////////////////// Delayms library /////////////////////////

void Delayms( unsigned t)
{
    T1CON = 0x8000;     // enable TMR1, Tpb, 1:1
    while (t--)
    {  // t x 1ms loop
        TMR1 = 0;
        while (TMR1 < FPB/1000);
    }
} // Delayms

////////////////// LCD enable library /////////////////////////
void _lcd_enable(void)
{

ENABLE = 0;
DI = 0;
RW = 0;
RESET = 1;
CS2 = 0;
CS1 = 1;
Delayms(10);
ENABLE = 1;
Delayms(10);
ENABLE = 0;
Delayms(10);

}
///////////////////////////////////////////
///////////////////////////////////////////
/////////////// Main //////////////////////
///////////////////////////////////////////
///////////////////////////////////////////

main ()
{
//////display on////////
LCD_TRIS = 0;
LCD_DATA = 0b00111111;
Delayms(10);
_lcd_enable();

//////set Y////////
LCD_DATA = 0b01000011;
Delayms(10);
_lcd_enable();

//////set X////////
LCD_DATA = 0b10111011;
Delayms(10);
_lcd_enable();

//////write 10101010////////
ENABLE = 1;
DI = 0;
RW = 0;
RESET = 1;
CS2 = 0;
CS1 = 1;
Delayms(10);
DI = 1;
Delayms(10);
LCD_DATA = 0b10101010;
ENABLE = 0;
Delayms(10);
}

by this code the leds in PORTD are on and off according to the code but the GLCD doesn't respond any signal

thanks
 

Re: GLCD problem

Hello Mostafa!

Before looking at your code:
1. Did you try what I wrote the other day? Could you verify that
every signal in your software is transmitted on the actual hardware?
For instance, assuming that RW is currently 0, if your source code
tells to make it high, dos the RW pin of your LCD actually change
to the right status?

2. Now I'm not going to debug your code, and I guess nobody will,
however, here are some remarks:
- The reset signal is never low. You set it to 1 at to different locations,
but never to 0. How do you reset your screen?
- The CS signals (and your ENABLE signal) look strange. For example
why do you set ENABLE to 0, then to 1, then again to 0 in the _lcd_enable
function. As for the CS1 and CS2, why do you always set the same value?
Did you read the specs of the KS 0108?

Dora

mostafa ewaiha said:
thanks all
my code :

[… code deleted …]

by this code the leds in PORTD are on and off according to the code but the GLCD doesn't respond any signal

thanks
 

GLCD problem

yes, I verify that every signal is true

I read the spec. of KS108 and it said that to switch the screen on or write data on screen the enable signal must be low and the instruction take place in the falling edge so I make enable 0-1-0.

Added after 51 minutes:

like my code
 

Re: GLCD problem

Hello Mostafa!

Yes, but I mean: if you need a falling edge, you don't need to set the signal
to 0, then to 1, then to 0.
You may do something like:

void strobe_data(void) {
ENABLE = 0; // falling edge
ENABLE = 1; // restoring the default status.
}

I call this function strobe rather than enable because enable already means
putting cs to 0.

Now look at your function: it has 11 lines. If you call this everytime you want to
enter 1 byte of data, then you will spend a lot of time waiting in the delay, and
your display will be awfully slow.

Last thing: the documentaion says that if you want to enable the display, then
CS1 and CS2 should be both 0. In your code, they have always the same
value: one is 0, the other is 1, which means that the LCD is never selected.


Dora

 

Re: GLCD problem

Always MPLAB's Compiler like C18 or C32 does not produce correct execution of the GLCD. Since the working of GLCD involves lot of steps even to write a single letter. Because of this reason only I switched to MIKRO C compiler. It has inbuilt library function to write,draw,graphical etc. It is very very simple to work with MIKRO C PRO compiler.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…