CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Graphic LCD WG12864A HELP

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

Graphic LCD WG12864A HELP
PostPosted: Mon Jun 07, 2010 10:27 am     Reply with quote

Dear friends,
I am an italian student and in the past I have found more very good info in this forum!!

Now....I need your help.

I have bought a a GLCD WG12864A and I think that it working with a KS0108 controller.
This is the datasheet: http://doc.chipfind.ru/pdf/winstar/wg12864a.pdf

So....I have downloaded the GLCD.C library and I have changed the port in this way:
Code:
#ifndef GLCD_C
#define GLCD_C

#ifndef GLCD_WIDTH
#define GLCD_WIDTH 128    // Used for text wrapping by glcd_text57 function
#endif

#define ON  1
#define OFF 0

#define YES 1
#define NO  0

#ifndef GLCD_CS1
#define GLCD_CS1 PIN_D3   // Chip Selection 1
#endif

#ifndef GLCD_CS2
#define GLCD_CS2 PIN_D4   // Chip Selection 2
#endif

#ifndef GLCD_DI
#define GLCD_DI  PIN_D0   // Data or Instruction input
#endif

#ifndef GLCD_RW
#define GLCD_RW  PIN_D1   // Read/Write
#endif

#ifndef GLCD_E
#define GLCD_E   PIN_D2   // Enable
#endif

#ifndef GLCD_RST
#define GLCD_RST PIN_D5   // Reset
#endif
-
-
-
-
-
-
-
-
-
void glcd_writeByte(char chip, BYTE data)
{
   if(chip == GLCD_CS1)       // Choose which chip to write to
      output_high(GLCD_CS1);
   else
      output_high(GLCD_CS2);

   output_low(GLCD_RW);       // Set for writing
   output_b(data);            // Put the data on the port
   output_high(GLCD_E);       // Pulse the enable pin
   delay_us(2);
   output_low(GLCD_E);

   output_low(GLCD_CS1);      // Reset the chip select lines
   output_low(GLCD_CS2);
}


// Purpose:       Reads a byte of data from the specified chip
// Ouputs:        A byte of data read from the chip
BYTE glcd_readByte(BYTE chip)
{
   BYTE data;                 // Stores the data read from the LCD
   if(chip == GLCD_CS1)       // Choose which chip to read from
      output_high(GLCD_CS1);
   else
      output_high(GLCD_CS2);

   input_b();                 // Set port d to input
   output_high(GLCD_RW);      // Set for reading
   output_high(GLCD_E);       // Pulse the enable pin
   delay_us(2);
   output_low(GLCD_E);
   delay_us(2);
   output_high(GLCD_E);       // Pulse the enable pin
   delay_us(2);
   data = input_d();          // Get the data from the display's output register
   output_low(GLCD_E);

   output_low(GLCD_CS1);      // Reset the chip select lines
   output_low(GLCD_CS2);
   return data;               // Return the read data
}



and this is the MAIN function:

Code:


#include "C:\Documents and Settings\Administrator\Dati applicazioni\PICC\Projects\main.h"
#include "C:\Documents and Settings\Administrator\Dati applicazioni\PICC\Projects\glcd.c"

void main()
{
delay_us(1000);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_CLOCK_DIV_2);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);


glcd_init (ON);
delay_us(1000);
glcd_fillScreen (0);

glcd_line(0, 0, 100, 60, 1);

}



I have simulated the compiled (main.hex) with PIC SIMULATOR IDE and it drawing correcly the line on GLCD.
I have controlled the pin of my PCB and all pin is right....but I can't see the line (or other pixel) on the GLCD....!
I have also connected Vee to GND with a potentiometer and the central pin of the potentiometer is connected to Vo (100k ohm).
Matching the potentiometer I can see the 128x64 pixel but i cannot see a line or other pixel on.

1) The RESET of the WG12864A is active with low voltage....is this the problem!!
2) Is the C code Right??
3) Is the library right for WG12864A GLCD??
4) The delay time is right??
5) How can i initialize my GLCD without library in simple mode for test??
6) PLEASE HELP ME ;)

Sorry for my very bad english and for the grammatical errors
Fabio Patriarca
IZ0CBG
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 11:35 am     Reply with quote

Anyone that can help me??
balmer



Joined: 31 May 2010
Posts: 6

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 1:07 pm     Reply with quote

Your graphic LCD is of the backlight type, I guess.
Have you driven current betwen the backlight pins of the display ?

pin 19 Anode
pin 20 katode

Salutti
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 1:16 pm     Reply with quote

Quote:
1) The RESET of the WG12864A is active with low voltage....is this the problem!!

The Reset pin is an output from the LCD. It shows the status of the
power-up internal initialization of the LCD. A low level indicates that
initialization is done, and the LCD is ready to accept commands. So
a low level is good.
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 1:17 pm     Reply with quote

balmer wrote:
Your graphic LCD is of the backlight type, I guess.
Have you driven current betwen the backlight pins of the display ?

pin 19 Anode
pin 20 katode

Salutti


Many thanks for the reply....
I have connected the Anode and Katode correctly.....with a 100 ohm resistor and the LED is turned on.
Any idea??

Thanks...Fabio
balmer



Joined: 31 May 2010
Posts: 6

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 2:26 pm     Reply with quote

The Reset pin is an input of the LCD.

You must set pin ...

output_high(GLCD_RST);

if not done, LCD will be set on reset status.
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 2:44 pm     Reply with quote

Thanks PCM and BALMER....
the initialization of the glcd.c library that I downloaded is:

Code:


// Inputs:        The initialization mode
//                OFF - Turns the LCD off
//                ON  - Turns the LCD on
// Date:          5/28/2003
void glcd_init(int1 mode)
{
   // Initialze some pins
   output_high(GLCD_RST);
   output_low(GLCD_E);
   output_low(GLCD_CS1);
   output_low(GLCD_CS2);

   output_low(GLCD_DI);                // Set for instruction
   glcd_writeByte(GLCD_CS1, 0xC0);     // Specify first RAM line at the top
   glcd_writeByte(GLCD_CS2, 0xC0);     //   of the screen
   glcd_writeByte(GLCD_CS1, 0x40);     // Set the column address to 0
   glcd_writeByte(GLCD_CS2, 0x40);
   glcd_writeByte(GLCD_CS1, 0xB8);     // Set the page address to 0
   glcd_writeByte(GLCD_CS2, 0xB8);
   if(mode == ON)
   {
      glcd_writeByte(GLCD_CS1, 0x3F);  // Turn the display on
      glcd_writeByte(GLCD_CS2, 0x3F);
   }
   else
   {
      glcd_writeByte(GLCD_CS1, 0x3E);  // Turn the display off
      glcd_writeByte(GLCD_CS2, 0x3E);
   }

   glcd_fillScreen(OFF);               // Clear the display
}



I think that the RST pin is set correctly yet.
no??
If the code is correct....the GLCD don't work again.
In the PIC SIMULATOR IDE Software....the GLCD draw a line but no circle and no text.

But I have one question....if the RST pin is an output of the LCD...I have to set it as an input for the PIC??

Many Thanks
Fabio
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 6:18 pm     Reply with quote

I have found an error on my GLCD.C. Changing PORT I have understood to change this in the read function:
Code:
 
 data = input_d();

in
Code:
 
 data = input_b();

because I use PORT B as data.

So...I have tested hex in PIC Simulator IDE and NOW.....it draw circle etc.
The problem is that programming the 16f877a....my REAL GLCD won't work.
Nothing of nothing :(

Please....some one can help me??

Thanks
Fabio
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group