Page 1 of 1

GLCD model JHD12864E

PostPosted: Sun Feb 12, 2012 4:12 pm
by Lam
My project is not using any Arduino's kit but using Atmega32 in my prototype project.
I've some questions to ask relate GLCD 128x64, model JHD12864E.

1) Is it my GLCD need install any software such as ProGFX to get its libraries and add to AVR Studio 4?
2) Is it must use 16MHz external crystal? Because I'm using 8MHz external crystal.
2) I'm referred PIC interface with GLCD and tried to translate it to my AVR C language, my GLCD display lights ON (dot pixels observed) but expected output didn't come out. (*I've connected 1k potentiometer)

If anyone faced same problems and solved, please guide me.
Thanks first. ;)

Re: GLCD model JHD12864E

PostPosted: Mon Feb 13, 2012 9:47 am
by yonghui
hi,

is the crystal is for the avr contoroller?

mayb u can show up some codes u write for the LCD. init code. write and read functions..

rgds,
yh

Re: GLCD model JHD12864E

PostPosted: Mon Feb 13, 2012 12:50 pm
by Lam
[/code]Hi yonghui,

Atmega32 itself has 8MHz and I'm using external crystal 8MHz too.
Below is my code, tried to understand from PIC and translate to my AVR C language.

CODE: SELECT_ALL_CODE
#include<avr/io.h>
#include<util/delay.h>
#include <avr/pgmspace.h>

//GLCD Module Connections
#define   GLCD_CPRT   PORTC
#define   GLCD_CDDR   DDRC
#define   GLCD_CPIN   PINC
#define GLCD_APIN   PINA
#define GLCD_APRT   PORTA
#define GLCD_ADDR   DDRA
#define   GLCD_BPRT   PORTB
#define   GLCD_BDDR   DDRB
#define   GLCD_BPIN   PINB

//Command Port Bits
#define   GLCD_CSEL1   0
#define   GLCD_CSEL2   1
#define   GLCD_RST   2
#define   GLCD_RS      5
#define   GLCD_RW      6
#define   GLCD_EN      7


void delay_us(unsigned int d)
{
   _delay_us(d);
}

void delay_ms(unsigned int d)
{
   _delay_ms(d);
}

void Enable_Pulse (void)
{
        GLCD_APRT |= (1<<GLCD_EN);   //E pin high
      delay_us(5);
        GLCD_APRT &= ~(1<<GLCD_EN);   //E pin low
      delay_us(5);
}

void GLCD_ON()
{
   GLCD_CDDR = 0xFF;
   GLCD_APRT = 0;
   GLCD_ADDR = 0xFF;
   GLCD_BPRT = 0;
   GLCD_BDDR = 0xFF;
   
   GLCD_BPRT |= (1<<GLCD_CSEL1);
   GLCD_BPRT |= (1<<GLCD_CSEL2);
   GLCD_APRT &= ~(1<<GLCD_RS);
   GLCD_APRT &= ~(1<<GLCD_RW);

   GLCD_CPRT = 0x3F;   //ON command
   Enable_Pulse();
}

void Set_Start_Line(unsigned short line)
{
   GLCD_CDDR = 0xFF;
   GLCD_APRT = 0;
   GLCD_ADDR = 0xFF;
   GLCD_BPRT = 0;
   GLCD_BDDR = 0xFF;
   
   
   GLCD_APRT &= ~(1<<GLCD_RS);
   GLCD_APRT &= ~(1<<GLCD_RW);
   //Activate both chips
   GLCD_BPRT |= (1<<GLCD_CSEL1);
   GLCD_BPRT |= (1<<GLCD_CSEL2);
   GLCD_CPRT = 0xC0 | line;   //Set Address
   Enable_Pulse();
}

void GOTO_COL(unsigned int x)
{
   unsigned short Col_Data;
   GLCD_CDDR = 0xFF;
   GLCD_APRT = 0;
   GLCD_ADDR = 0xFF;
   GLCD_BPRT = 0;
   GLCD_BDDR = 0xFF;
      
   GLCD_APRT &= ~(1<<GLCD_RS);
   GLCD_APRT &= ~(1<<GLCD_RW);
   
   if(x<64)   //Left Half
   {
      GLCD_BPRT |= (1<<GLCD_CSEL1);   //Select Chip1
      GLCD_BPRT &= ~(1<<GLCD_CSEL2);   //Deselect Chip2
      Col_Data = x;
   }
   else
   {
      GLCD_BPRT |= (1<<GLCD_CSEL2);   //Select Chip2
      GLCD_BPRT &= ~(1<<GLCD_CSEL1);   //Deselect Chip1
      Col_Data = x-64;      //Put column address on data port
   }
   Col_Data = (Col_Data | 0x40) & 0x7F;   //Command format
   GLCD_CPRT = Col_Data;
   Enable_Pulse();
}

void GOTO_ROW(unsigned int y)
{
   unsigned short Row_Data;
   GLCD_CDDR = 0xFF;
   GLCD_APRT = 0;
   GLCD_ADDR = 0xFF;
   GLCD_BPRT = 0;
   GLCD_BDDR = 0xFF;

   GLCD_APRT &= ~(1<<GLCD_RS);
   GLCD_APRT &= ~(1<<GLCD_RW);
   Row_Data = (y | 0xB8) & 0xBF;   //Put row address on data port
   GLCD_CPRT = Row_Data;
   Enable_Pulse();
}

void GOTO_XY(unsigned int x,unsigned int y)
{
   GOTO_COL(x);
   GOTO_ROW(y);
}

void GLCD_Write(unsigned short b)
{
   GLCD_CDDR = 0xFF;
   GLCD_APRT = 0;
   GLCD_ADDR = 0xFF;
   GLCD_BPRT = 0;
   GLCD_BDDR = 0xFF;

   GLCD_APRT |= (1<<GLCD_RS);
   GLCD_APRT &= ~(1<<GLCD_RW);
   GLCD_CPRT = b;
   delay_us(1);
   Enable_Pulse();
}

unsigned short GLCD_Read(unsigned short column)
{
   unsigned short read_data = 0;   //Read data here
   GLCD_CDDR = 0x00;
   GLCD_APRT = 0;
   GLCD_ADDR = 0xFF;
   GLCD_BPRT = 0;
   GLCD_BDDR = 0xFF;

   GLCD_APRT |= (1<<GLCD_RS);
   GLCD_APRT |= (1<<GLCD_RW);
   if(column>63)
      GLCD_BPRT = (1<<GLCD_CSEL1);
   else
      GLCD_BPRT = (1<<GLCD_CSEL2);   //Disable/Enable CSEL2
   delay_us(1);
   GLCD_APRT |= (1<<GLCD_EN);   //Latch RAM data into ouput register
   delay_us(1);

   //Dummy read to fetch data from the display RAM
       GLCD_APRT &= ~(1<<GLCD_EN);   //Low Enable
       delay_us(5);
       GLCD_APRT |= (1<<GLCD_EN);   //latch data from output register to data bus
       delay_us(1);             

       read_data = GLCD_CPRT;      //Input data
       GLCD_APRT &= ~(1<<GLCD_EN);     //Low Enable to remove data from the bus
       delay_us(1);
       GLCD_CDDR = 0xFF;           //PORTC is Output again
       return read_data;
}

void GLCD_ClrIn(unsigned short In)
{
   int i;
   GOTO_XY(0,In);   //At start of line of left side
   GOTO_XY(64,In);   //At start of line of right side
   GLCD_BPRT |= (1<<GLCD_CSEL1);
   for(i=0;i<65;i++)
      GLCD_Write(0);
}

void GLCD_CLR()
{
   unsigned short m;
   for(m=0;m<8;m++)
   {
      GLCD_ClrIn(m);
   }
}

void Draw_Point(unsigned short x,unsigned short y, unsigned short color)
{
    unsigned short Col_Data;;
    GOTO_XY(x,(y/8));
    switch (color)
    {
        case 0:         //Light spot
            Col_Data = ~(1<<(y%8)) & GLCD_Read(x);
        break;
        case 1:         //Dark spot
            Col_Data = (1<<(y%8)) | GLCD_Read(x);
        break;
    }
    GOTO_XY(x,(y/8));
    GLCD_Write(Col_Data);
}

int main(void)
{
   unsigned short u, v;
   
   GLCD_CDDR = 0x00;
    GLCD_BDDR = 0x00;
   GLCD_ADDR = 0x00;
    GLCD_BPRT = 0x00;
   GLCD_APRT = 0x00;
    GLCD_CPRT = 0x00;
    
   GLCD_BPRT &= ~(1<<GLCD_CSEL1);   // De-Activate both chips
    GLCD_BPRT &= ~(1<<GLCD_CSEL2);
    GLCD_BPRT |= (1<<GLCD_RST);
    GLCD_ON();
    GLCD_CLR();
    Set_Start_Line(0);
    do
   {
      for(u=0; u<64; u+=6)
            for(v=0; v<128; v+=2)
               Draw_Point(v, u, 1);
            delay_ms(1000);
            GLCD_CLR();
            delay_ms(1000);
   }
   while(1);
}

Re: GLCD model JHD12864E

PostPosted: Wed Feb 22, 2012 10:13 pm
by Lam
Hi all,

Is there anyone know how to display sentence on this GLCD JHD12684E? Such as "Hello"...
I hope those who expert in GLCD controller KS0108 can guide me.

Thanks. ;)

Re: GLCD model JHD12864E

PostPosted: Thu Feb 23, 2012 1:07 pm
by ABSF
Lam WROTE:Hi all,

Is there anyone know how to display sentence on this GLCD JHD12684E? Such as "Hello"...
I hope those who expert in GLCD controller KS0108 can guide me.

Thanks. ;)


I am not an expert in KS0108, just have bought one last year from China with a demo board.

From the datasheet there is no character ROM built in the chip so I am afraid you have to construct your own character set and display them on the GLCD as a picture. The link below is a good source of imformation that might be helpful to you. I haven't started to play with my GLCD yet due to lack of spare time. :(

http://extremeelectronics.co.in/avr-tut ... h-avr-mcu/

If you scroll down to the middle of the page you will see 4 tutorials

Other Parts of the Tutorial Series
Part I - Introduction to GLCD and Hardware Setup
Part II - Downloading and Installing ProGFX!
Part III - Explains Graphic Primitive Functions.
Part IV - Font and Text Handling Functions.


Part IV is the one you're most interested and it is worth reading. :)

Allen

Re: GLCD model JHD12864E

PostPosted: Fri Feb 24, 2012 10:12 pm
by Lam
Thx ABSF for the link, I was review this link before.
Same still, my GLCD display all dots.
I guess my software don't have any driver can direct call such as PIC microcontroller.
PIC can straight away call driver out and write characters out, which is more easier.

Re: GLCD model JHD12864E

PostPosted: Mon Feb 27, 2012 11:55 am
by kl84
Lam WROTE:Same still, my GLCD display all dots.

Perhaps LCD is not properly initialized. Try to play with that part?

Re: GLCD model JHD12864E

PostPosted: Wed Feb 29, 2012 10:13 am
by Lam
Perhaps LCD is not properly initialized. Try to play with that part?


If based on my coding that I posted, is it my initialize not complete?
I hope here have ny advice and correction to me. =)