LCDInfo.com

http://www.lcdinfo.com
It is currently Thu Nov 21, 2024 22:29

All times are UTC + 2 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Oct 14, 2003 14:08 
Anyone used ATMega16 with T6963C ?
I'm having a hard time trying to figure out where to get a header to drive the display...

If anyone would have a file to drive the display, I would prehissiate it very much :p

It would be good if it was written in c instead of asm...

Thanks,
Mika Blom


Top
  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 16:53 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Well not Mega16 but I've been using a T6963C display with Mega32. Should be pretty much the same thing.

I'll do some copy pasting below from some project of mine. It's for GCC.
Code:
#include <avr/io.h>

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

#define CD_0    0
#define CD_1    0x08

#define CE_0    0
#define CE_1    0x01

#define RD_0    0
#define RD_1    0x02

#define WR_0    0
#define WR_1    0x04


#define DATAPORT      PORTA
#define CONTROLPORT   PORTC


void wait(unsigned int value)
{
        volatile unsigned i=0;
        for(i=0;i<value;i++)
   asm volatile("nop");
}

static void WriteCtrl(unsigned char cmd)
{
    outb(DDRA, 0xFF); // databus output
    outp(cmd, DATAPORT);
    outp(CD_1 | CE_0 | RD_1 | WR_0, CONTROLPORT);
    wait(0);
    outp(CD_1 | CE_1 | RD_1 | WR_1, CONTROLPORT);
}

void WriteData(unsigned char dat)
{
    outb(DDRA, 0xff); // databus output
    outp(dat, DATAPORT);
    outp(CD_0 | CE_0 | RD_1 | WR_0, CONTROLPORT);
    wait(0);
    outp(CD_0 | CE_1 | RD_1 | WR_1, CONTROLPORT);
}

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)
{
  unsigned short 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 T_BASE alkuun

  for (i=0;i<320;i++) {
        WriteData(0); WriteCtrl(0xc0); // kirjoita data ja inc ptr
  }
}

void ClearLCDGraph(void)
{
  int i;

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

  for (i=0;i<2560;i++){
        WriteData(0); WriteCtrl(0xc0); // kirjoita data ja inc ptr
  }
}

void PrintLCDChar(unsigned char ch)
{
        WriteData(ch - ' ');
        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)));
}

int main (void)
{
    int i,j;

    outb(DDRA, 0xFF); // lcd, FTDI data bus output
    outb(DDRC, 0xCF); // lcd control pins output

    InitLCD();
    ClearLCDText();
    ClearLCDGraph();
    SetLCDXY(0,0);
   
    PrintLCDChar('H');
    PrintLCDChar('e');
    PrintLCDChar('l');
    PrintLCDChar('l');
    PrintLCDChar('o');
    PrintLCDChar('!');

    for(i=10;i<100;i++)
    {
        for(j=20;j<30;j++)
        {
            SetLCDPixel(i,j);
        }
        for(j=20;j<30;j++)
        {
            ClearLCDPixel(i-1,j);
        }
    }

}

I stripped a lot of the code and the code above isn't tested but this should be the basics to get something on a T6963C lcd.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 16:58 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Also moving this into the development forum which has more discussion about programming.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 18:50 
Aaah,
Thanks, alot!
I owe you one :)


Top
  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 12:26 
Offline

Joined: Tue Aug 24, 2004 9:35
Posts: 10
Hi Henri
I read your code posted for T6963c, and it is very useful. It let me able to use T6963c straight the way. Thanks.

I just want to ask that is it possible for you to show me how to write reading status function of the lcd?

I tried to write my own reading status function, but it always lock up in the reading status function, and display nothing.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 23:00 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
lcduser wrote:
I just want to ask that is it possible for you to show me how to write reading status function of the lcd?

Hi, I replied in your other topic about the same thing: http://forum.lcdinfo.com/viewtopic.php?t=1086


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 14, 2009 15:48 
Offline

Joined: Sat Mar 14, 2009 15:42
Posts: 1
Hi!

I'm using ATmega 16 and Winstar 240x128 graphic display with T6963C driver. I tried the code above with context (www.contexteditor.org), but it doesn't understand outp and outb macros. Is there a way to enable those commands or should I use some other commands? What would they be?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 15, 2009 11:04 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
The following would probably be more compatible with the more recent AVRGCC versions:

Code:
void WriteData(unsigned char dat)
{
    DDRA = 0xff; // databus output
    DATAPORT = dat;
    CONTROLPORT = CD_0 | CE_0 | RD_1 | WR_0;
    wait(0);
    CONTROLPORT = CD_0 | CE_1 | RD_1 | WR_1;
}


Of course you could also define your own outp and outb macros if you like.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2012 7:25 
Offline

Joined: Tue Sep 04, 2012 7:22
Posts: 1
very useful thank u man
very thank u


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 9 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group