LCDInfo.com

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

All times are UTC + 2 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Mar 26, 2003 6:02 
hey guys

i have a dmf-5005 ny/ly/ake lcd (uses the t6963 controller).

i have got it hooked up to an atmel mega128 processor (data on port c and control on port d - wr=bit6, rd=bit7, ce=bit4, cd=bit5, reset=bit1)

i am using c to program the microcontroller.

i have attempted the initialisation routine, suggested in the datasheets, but to no avail. the screen still stays blank.

can someone help me please?
my c code is as follows... sorry its so long.....

thanx
simon

Code:
//ICC-AVR application builder : 13/03/2003 5:28:00 PM
// Target : M128
// Crystal: 8.0000Mhz

#include <iom128v.h>
#include <macros.h>

//LCD control bits

#define LCD_CE_on  PORTD |= 0x10            //turn CE on (PD4)
#define LCD_CE_off PORTD &= ~0x10            //turn CE off (PD4)
#define LCD_CD_on  PORTD |= 0x20            //turn CD on (PD5)
#define LCD_CD_off PORTD &= ~0x20            //turn CD off (PD5)
#define LCD_WR_on  PORTD |= 0x40            //turn WR on (PD6)
#define LCD_WR_off PORTD &= ~0x40            //turn WR off (PD6)
#define LCD_RD_on  PORTD |= 0x80            //turn RD on (PD7)
#define LCD_RD_off PORTD &= ~0x80            //turn RD off (PD7)
#define LCD_reset_on   PORTD |= 0x02         //turn reset on (PD1)
#define LCD_reset_off  PORTD &= ~0x02         //turn reset off (PD1)


void port_init(void)
{
 PORTA = 0xFF;
 DDRA  = 0xFF; //output
 PORTB = 0x00;
 DDRB  = 0xFF;
 PORTC = 0x00; //m103 output only
 DDRC  = 0xFF;
 PORTD = 0x02;
 DDRD  = 0xFF;
 PORTE = 0xFF;
 DDRE  = 0xFF;
 PORTF = 0xFF;
 DDRF  = 0xFF;
 PORTG = 0x10;
 DDRG  = 0xFF;
}

//Comparator initialisation
// trigger on: Output toggle
void comparator_init(void)
{
 ACSR = ACSR & 0xF7; //ensure interrupt is off before changing
 ACSR = 0x00;
}

//ADC initialisation
// Conversion time: 3uS
void adc_init(void)
{
 ADCSRA = 0x00; //disable adc
 ADMUX = 0x00; //select adc input 0
 ACSR  = 0x00;
 ADCSRA = 0x01;
}

//call this routine to initialise all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 XDIV  = 0x00; //xtal divider
 XMCRA = 0x00; //external memory
 port_init();
 comparator_init();
 adc_init();

 MCUCR = 0x00;
 EICRA = 0x00; //extended ext ints
 EICRB = 0x00; //extended ext ints
 EIMSK = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 ETIMSK = 0x00; //extended timer interrupt sources
 SEI(); //re-enable interrupts
 //all peripherals are now initialised
}

void Delay()
   {
   unsigned char a, b;

   for (a = 1; a; a++)
      for (b = 1; b; b++)
         ;
   }


int getstatus(void)
{
     int status;
    int statusok;
    int statuschk;
   
   //set up port d
   LCD_CD_on;
   LCD_RD_off;
   LCD_WR_on;
   LCD_CE_off;
   _NOP();           //>150ns?? delay before read
   _NOP();
   _NOP();
   
     DDRC  = 0x00; //input
    PORTC = 0xFF; //pull up
   
    status = PINC; //get status
   // statusok = 0x03; //what status is supposed to look like
   
    LCD_CE_on;        //take CE high again
    LCD_RD_on;        //disable read mode
    DDRC  = 0xFF;      //output
    PORTC = 0x00;      //zeros
   
   // statuschk = status & statusok; //filter out higher bits
   
    // debug - show status
    PORTB = status;
    Delay();
    Delay();
    PORTB = 0x00;
    Delay();
    Delay();
    //
       
   return (status);
}
   
   
void main()
   {
   int i;
   int j;
   int k;
   init_devices();
   /*         
   //reset
   LCD_reset_off;
   _NOP(); //length of time ??
   _NOP();
   LCD_reset_on;
   _NOP();
   _NOP();
   LCD_reset_off;
   _NOP();
   _NOP();
   LCD_reset_on;
   _NOP();
   _NOP();
   */
   
   
   //initialise   
      
   //mode set
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x80;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   
   
   
   //control word set
   //1
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x00;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //2   
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x00;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
      
   //3
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x42;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //number of graphic area set
   //1
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x1E;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //2
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x00;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //3
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x43;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //text home position set
   //1
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x00;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //2
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x00;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //3
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x40;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //number of text area set
   //1
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x1E;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //2
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x00;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //3
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x41;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //address pointer set
   //1
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x23;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //2
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x01;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //3
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x24;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;   
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
      
   //test
   //data
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x21;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //command
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0xC0;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
      //data
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x21;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //command
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0xC0;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
      //data
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x21;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //command
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0xC0;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
      //data
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x21;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //command
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0xC0;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
      //data
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x21;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //command
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0xC0;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
      //data
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0x21;
   LCD_CD_off;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   //command
   do {}
   while((0x03 & getstatus()) !=0x03);
   PORTC = 0xC0;
   LCD_CD_on;
   LCD_WR_off;
   LCD_RD_on;
   LCD_CE_off;
   _NOP();
   LCD_CE_on;
   LCD_WR_on;
   
   // debug
   for(;;)
   {
   PORTB = 0x0F;
   Delay();
   Delay();
   Delay();
   PORTB = 0x00;
   Delay();
   Delay();
   Delay();
   }

   
   }


Top
  
 
 Post subject:
PostPosted: Wed Mar 26, 2003 6:04 
Offline

Joined: Wed Mar 26, 2003 5:50
Posts: 2
sorry.....this was me....

cheers simon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2003 17:28 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
I have used the following code with 240x64 T6963C display and PIC16F877. I also have couple AVR8535 chips here waiting but haven't had time to test them yet.

Busy flag checking isn't used in this one but I've used it in some other version of this code.

Code:
#define G_BASE 0x0200
#define T_BASE 0x0000
#define BYTES_PER_ROW 40

// change these to match your wiring
#define CD_0    0
#define CD_1    0x01

#define CE_0    0
#define CE_1    0x08

#define RD_0    0
#define RD_1    0x02

#define WR_0    0
#define WR_1    0x04

#define OUTPUT_CONTROL        PORTA
#define OUTPUT_DATA          PORTB
#define INPUT_DATA           PORTB
#define NOP      asm{nop}


static void WriteCtrl(unsigned char cmd)
{
        TRISB = 0;

        OUTPUT_CONTROL = CD_1 | CE_0 | RD_1 | WR_0;
        OUTPUT_DATA = cmd;
        OUTPUT_CONTROL = CD_1 | CE_1 | RD_1 | WR_1;
}

static void WriteData(unsigned char dat)
{
        TRISB = 0;

        OUTPUT_CONTROL = CD_0 | CE_0 | RD_1 | WR_0;
        OUTPUT_DATA = dat;
        OUTPUT_CONTROL = CD_0 | CE_1 | RD_1 | WR_1;
}

static 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);
}

static 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);
}

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

static 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
  }
}

static 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
  }
}

static void PrintLCDChar(unsigned char ch)
{
        WriteData(ch - ' ');
        WriteCtrl(0xc0);
}



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

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 29 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:  
cron
Powered by phpBB® Forum Software © phpBB Group