LCDInfo.com
http://forum.lcdinfo.com/

Programming a T6963C (Visual Basic)
http://forum.lcdinfo.com/viewtopic.php?f=9&t=127
Page 1 of 11

Author:  Marc [ Thu Feb 06, 2003 0:42 ]
Post subject:  Programming a T6963C (Visual Basic)

Hi all!

First of all, sorry for my poor english.

I have read all the posts that you have posted in this forum and I tried to program a very simple application that initializes the LCD, and write pixels using the functions that you have posted.

I found some problems in the sbrSetPixel, my LCD doesn't display all the pixels, specially the last X coordinates.

I will agree any help that you can give me.

Thanks everyone.

PD: PowerLCD works fine with my LCD, i will know how this program draw pixels.

Author:  Marc [ Thu Feb 06, 2003 12:03 ]
Post subject:  Sorry

Sorry, in the post I don't say which is my LCD.

LCD 240x128, controlled by Toshiba T6963C.

The pins are this:
D0-D7: Pin 2 - Pin 9
CE: Pin 1
C/D: Pin 17
RD: Pin 14
WR: Pin 16

All this pins are the parallel port.

Thanks.

Author:  Henri [ Thu Feb 06, 2003 14:53 ]
Post subject: 

Could you also tell the settings you are using in the initialization. Are you programming in C ?

Author:  Marc [ Thu Feb 06, 2003 17:03 ]
Post subject:  Initialization

I'm programming in Visual Basic .NET but I understand C code, in the initialization, i use

G_BASE = &H300
T_BASE =&H0
BYTES_X_ROW = 40

Are u asking this ¿?

Thanks

Author:  Marc [ Fri Feb 07, 2003 0:32 ]
Post subject:  Bufff.

I passed hours trying to implement the functions that you hace posted in the post of Visual Basic.

But there are no way to make this functionality.

I will agree anyone who can help me posting the basic code (Init, PutPixel, ClearText, ... ) in C or in VB for my LCD. I tryed all the functions that Henri have posted, but i have a lot of problems, i think in timing, i don't know sure

A lot of thanks.

Author:  MaikRutsche [ Fri Feb 07, 2003 4:59 ]
Post subject: 

Are u german?

It would be more easy for me to explain how to control the T6963.

Do you have the datasheet of the T6963?
You will find all information in there.

Author:  Henri [ Fri Feb 07, 2003 11:11 ]
Post subject: 

Ok, I can post some T6963C test program code later.

Author:  Marc [ Fri Feb 07, 2003 12:36 ]
Post subject:  Thanks

Thanks all, i'm not German.

I'm Catalan.

I have the T6963C datasheet, but i don't know why i have all this problems.

Thanks for helping me :cry: :cry: :cry: :cry:

Author:  Henri [ Fri Feb 07, 2003 18:45 ]
Post subject: 

This code worked fine for me with 240x128 display using the powerlcd wiring:

Code:
#define G_BASE 0x0300   // grafiikkamuistin base address
#define T_BASE 0x0000   // tekstimuistin base address
#define BYTES_PER_ROW 40 // merkkiä rivillä

#define BASE 0x378      // lpt portin osoite

void WaitDisplayReady(void)
// reads the display status byte and checks
// that the display is ready before writing

// doesn't have any check in case the status byte
// can't be read so this situation may cause a lockup

{
 
  int Tmp;

       Tmp = DlPortReadPortUshort(BASE + 0x402);
       Tmp = Tmp & 0x1F;
       Tmp = Tmp | 0x20;
       DlPortWritePortUshort(BASE + 0x402, Tmp);

       do{
             DlPortWritePortUshort(BASE + 2, 0x20 + 4 + 2);     //In, CD=1, CS=0, Wr=1
             DlPortWritePortUshort(BASE + 2, 0x20 + 4 + 2 + 8); //In, CD=1, CS=0, Wr=1, Rd=0
             Tmp = DlPortReadPortUshort(BASE);
             DlPortWritePortUshort(BASE + 2, 0x20 + 4 + 2);     //In, CD=1, CS=0, Wr=1

       }while ((Tmp & 3) != 3 );
       DlPortWritePortUshort(BASE + 2, 0);
   
}

void WriteData(USHORT Data)
{

    /* pollin
   WaitDisplayReady();
    DlPortWritePortUshort(BASE + 2, 0);   // 0111 C/D low
    DlPortWritePortUshort(BASE + 2, 2);   // 0011 WR low
    DlPortWritePortUshort(BASE, Data);
    DlPortWritePortUshort(BASE + 2, 3);   // 0010 CE low
    DlPortWritePortUshort(BASE + 2, 2);   // 0011 CE high
    DlPortWritePortUshort(BASE + 2, 0);   // 0111 WR high
   */

   /* powerlcd */
   DlPortWritePortUshort(BASE + 2, 0x0c);   // 0111 C/D low
   DlPortWritePortUshort(BASE + 2, 0x08);   // 0011 WR low
   DlPortWritePortUshort(BASE, Data);
   DlPortWritePortUshort(BASE + 2, 0x09);   // 0010 CE low
   DlPortWritePortUshort(BASE + 2, 0x08);   // 0011 CE high
   DlPortWritePortUshort(BASE + 2, 0x0c);   // 0111 WR high
   
}

void WriteCtrl(USHORT Command)
{

   /*
   WaitDisplayReady();
    DlPortWritePortUshort(BASE, Command);
    DlPortWritePortUshort(BASE + 2, 4);      // 1111 C/D high
    DlPortWritePortUshort(BASE + 2, 4+2);      // 1011 WR low
    DlPortWritePortUshort(BASE + 2, 4+3);      // 1010 CE low
    DlPortWritePortUshort(BASE + 2, 4+2);      // 1011 CE high
    DlPortWritePortUshort(BASE + 2, 0);      // 0111 C/D low
   */

   /* powerlcd */
   DlPortWritePortUshort(BASE + 2, 0x04);      // 1111 C/D high
   DlPortWritePortUshort(BASE + 2, 0x00);      // 1011 WR low
   DlPortWritePortUshort(BASE, Command);
   DlPortWritePortUshort(BASE + 2, 0x01);      // 1010 CE low
   DlPortWritePortUshort(BASE + 2, 0x00);      // 1011 CE high
   DlPortWritePortUshort(BASE + 2, 0x0c);      // 0111 C/D low
}

void InitLCD(void)
{
  // Display init
  WriteData(T_BASE & 0xFF);   // Data1: LowAddress
  WriteData(T_BASE >> 8);     // Data2: HighAddress
  WriteCtrl(0x40);            // Command: 0x40 -> 01000000

  WriteData(BYTES_PER_ROW);  // Data1: Colums
  WriteData(0);              // Data2: 0
  WriteCtrl(0x41);           // Command: 0x41 -> 01000001

  WriteData(G_BASE & 0xFF);  // Data1: LowAddress
  WriteData(G_BASE >> 8);    // Data2: HighAddress
  WriteCtrl(0x42);           // Command: 0x42 -> 01000010

  WriteData(BYTES_PER_ROW);  // Data1: Colums
  WriteData(0);              // Data2: 0
  WriteCtrl(0x43);           // Command: 0x43 -> 01000011

  // Internal CGROM Mode, OR Mode
  WriteCtrl(0x80); // OR Mode    // 80->10000000

  WriteCtrl(0xa7); // cursor is 8 lines high
  WriteData(0x00);
  WriteData(0x00);
  WriteCtrl(0x21); // put cursor at (x,y)

  // DisplayMode
  WriteCtrl(0x9D);
}

void SetLCDXY(int x, int y)
{
int addr;
  addr = T_BASE + (y * BYTES_PER_ROW) + x;
  WriteData(addr & 0xFF);
  WriteData(addr >> 8);
  WriteCtrl(0x24);
}

void SetLCDCursor(int x, int y)
{
  WriteData(x);
  WriteData(y);
  WriteCtrl(0x21);
}

void ClearLCDText(void)
{
  int i;

  WriteData(T_BASE & 0xFF);
  WriteData(T_BASE >> 8);
  WriteCtrl(0x24);      // address pointer to T_BASE

  for (i=0;i<640;i++) {
        WriteData(0); WriteCtrl(0xc0); // write data and inc ptr
  }
}

void ClearLCDGraph(void)
{
  int i;

  WriteData(G_BASE & 0xFF);
  WriteData(G_BASE >> 8);
  WriteCtrl(0x24); // address pointer to G_BASE

  for (i=0;i<5120;i++){
        WriteData(0); WriteCtrl(0xc0); // write data and inc ptr
  }
}

void PrintLCDText(char *string)
{
  unsigned int i;
  char c;

  for (i=0;i<strlen(string);i++){
        c = string[i] - 0x20; // conversion from ASCII to LCD characters
        if (c<0) c=0;
        WriteData(c);
        WriteCtrl(0xc0);
  }
}

void SetLCDPixel(int x, int y)
{
  int addr;

  addr = G_BASE + (y*BYTES_PER_ROW) + (x/6);
  WriteData(addr & 0xFF);
  WriteData(addr >> 8);
  WriteCtrl(0x24);
  WriteCtrl(0xf8 | (5-(x % 6)));
}

void ClearLCDPixel(int x, int y)
{
  int addr;

  addr = G_BASE + (y*BYTES_PER_ROW) + (x/6);
  WriteData(addr & 0xFF);
  WriteData(addr >> 8);
  WriteCtrl(0x24);
  WriteCtrl(0xf0 | (5-(x % 6)));
}


void main(void)
{
  InitLCD();
  ClearLCDText();
  ClearLCDGraph();
  SetLCDXY(2,7);
  PrintLCDText("Text juttu lisaa");

  for(int i=0;i<240;i++)
     for(int j=10;j<50;j++)
         SetLCDPixel(i,j);
 
  for(int k=110;k<150;k++)
     for(int l=20;l<30;l++)
        ClearLCDPixel(k,l);

  for(int m=10;m<20;m++)
     for(int n=20;n<30;n++)
        ClearLCDPixel(m,n);

}

Author:  Marc [ Fri Feb 07, 2003 22:29 ]
Post subject:  Thanks for the code

A lot of thanks Henri,

I 'm going to try it now

I will comment the results.

Thanks again :D

Author:  Marc [ Fri Feb 07, 2003 23:07 ]
Post subject:  Well

Thanks to your code I have discovered my problems.
It seems that the iterative cycles (for statements) didn't work properly, but i have solutioned yet.

PD: If you would I can paste the code that I translate for VB .NET.

A lot of thanks, :oops: :oops: :oops:

Author:  Henri [ Sun Feb 09, 2003 11:26 ]
Post subject: 

I'd like to see you posting your VB .NET code here if possible. :)

Author:  Marc [ Mon Feb 10, 2003 22:23 ]
Post subject:  Ok !!

Ok! I will put the code on Wednesday, cause i'm in exams.

Bye !

Author:  Henri [ Tue Feb 11, 2003 18:31 ]
Post subject: 

No need to hurry :)

Author:  Marc [ Wed Feb 19, 2003 20:35 ]
Post subject:  Today night

Today night i will post the code translation into VB.NET

I don't understand your language, so i don't know what you say ... sorry
(ADMIN EDIT: Marc means these posts)

Thanks, and wait until night, please.

Sorry for the late...

Bye !

Page 1 of 11 All times are UTC + 2 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/