LCDInfo.com

http://www.lcdinfo.com
It is currently Thu Mar 28, 2024 12:16

All times are UTC + 2 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Wed Mar 26, 2003 9:53 
Offline

Joined: Wed Mar 26, 2003 5:58
Posts: 2
I have seen how helpfull henri has been, and was impressed and hopefull that I could receive some help here.

I have got to interface this LCD to a Atmel Mega 128 processor. At the present stage, after following all the information provided to me through data sheets etc, i cannot get it to display a single thing... 8O

The language i am using is C.

This is my code so far, just for initialisation....and i get nothing....?

Code:
//ICC-AVR application builder : 3/20/2003 5:32:05 PM
// Target : M128
// Crystal: 8.0000Mhz

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

//# define for LCD controls
#define CELO   PORTA &= 0xBF       //set chip enable on
#define CEHI   PORTA |= ~0xBF     //set chip enable off
#define WRLO   PORTG &= 0x1B     //set write signal enable
#define WRHI   PORTG |= ~0x1B     //set write signal off
#define RDLO   PORTA &= 0x7F     //set read sig enable
#define RDHI   PORTA |= ~0x7F     //set read sig off
#define CDLO   PORTA &= 0xDF     //set CD sig low
#define CDHI   PORTA |= ~0xDF     //set CD high
#define Reset_on    PORTA &= 0xEF      //reset LCD
#define Reset_off    PORTA |= ~0xEF      //stop reset

#define reset       PORTF = 0x00      //turn off LED's

//#define for LED indicators on and off
#define LED_STS1     PORTF |= 0x04   //turn status LED on
#define LED_STS0     PORTF &= ~0x04 //turn status LED off

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

void Delay_L(void)                   //this is a visible delay (long)
   {
   int x ;                           //define variables used
   unsigned char  y, z;

   for (x = 1; x<25; x++)
      {
      //PORTF = 0x04 ;            //turn on LED to indicate at this position
      for (y = 1; y; y++)
         {
         for (z = 1; z; z++)
         {
         _NOP() ;                   //perform no operation
         _NOP() ;
         _NOP() ;
         }
         //PORTF = 0x00 ;         //turn off indicator LED
         }
      } 
   }
   
void Delay(void)                    //short delay - cannot be detected by human eye
    {
    unsigned char  a, b;
    for (a=1; a; a++)
        for (b=1; b; b++)
           ;
    }
   
   
//call this routine to initialise all peripherals
void init_devices(void)                   /*This routine is inserted by the built in wizard*/
{
                             //stop errant interrupts until set up
 CLI();                      //disable all interrupts
 XDIV  = 0x00;                   //xtal divider
 XMCRA = 0x00;                   //external memory
 port_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 CE_strobe(void)            //takes chip enable low and then high
    {                        //after a short delay
     CELO ;
     _NOP() ;
     _NOP() ;
     CEHI ;
     return ;
     }

unsigned char Status_return(void) //enables specfic status check
      {                               //returns full status for user to check in main code
      unsigned char status1 ;      //variable for storing status
     DDRC = 0x00 ;               //sets up port c for input
     CDHI ;                        //sets up ports correctly for reading in from LCD
     RDLO ;
     WRHI ;
     CELO ;
     Delay() ;
     status1 = PINC ;            //reads the values on all pins of port C
     CEHI ;
     DDRC = 0xFF ;
     return (status1) ;            //returns the status to the main
       }


void Status_chk(void)              //a generic status check with pins 1 & 2 not busy
      {                           //returns to position when called & executed
     unsigned char status2, w ;      //continues to check until status ok
     DDRC = 0x00 ;               //sets up port c for input
     CDHI ;                        //sets up ports correctly for reading in from LCD
     RDLO ;
     WRHI ;
    
     do
         {
      CELO ;                  //set CE low
      _NOP() ;
      _NOP() ;
      status2 = PINC ;            //read status of port C
      CEHI ;                      //sets ce high again
      w = status2 & 0x03 ;         // does logical and with 0000 0011
      }
       while (w != 0x03) ;         //this checks if status of bits 0 & 1 is ok to go
     DDRC = 0xFF ;                 //set portC back to output port
        //port_init() ;            //reset ports to orig and these must be
                             //set by each operation after status check
     //LED_STS1 ;                  //turns on LED's to indicate that status is ok.
     return ;
     }
    
void data_w(void)
    {
     CDLO ;                   //setting ports for a data write
     WRLO ;                  //CD taken low, WE low, RD hi
     RDHI ;
     Status_chk() ;            //check LCD status for write
     CE_strobe() ;              //strobe chip enable to write data
     return ;
    }
   
void data_r(void)
    {
     CDLO ;
     RDLO ;
     WRHI ;
     return ;
    }
   
void command_w(void)
    {
     CDHI ;
     WRLO ;
     RDHI ;
     Status_chk() ;
     CE_strobe() ;
     return ;
    }
   
void LCD_init(void)
    {
     //mode
     PORTC = 0x80 ;             //put 0x80 to port C to set mode of LCD
                                  //"or" mode with built in ROM enabled
     command_w() ;               //write command to LCD controller

     //control word - graphic home add
     PORTC = 0x00 ;             //put 00 on port C twice to set graphic home add
     data_w() ;                  //and write it to the LCD
     PORTC = 0x00 ;
     data_w() ;
     PORTC = 0x42 ;            //put 0x42 on port C - signifies Graphic home add
     command_w() ;               //write to LCD

     //graphic area
     PORTC = 0x1E ;               //set graphics area - 1E is 30 columns
     data_w() ;
     PORTC = 0x00 ;
     data_w() ;
     PORTC = 0x43 ;            //graphic area command tag
     command_w() ;
   
     //text home address
     PORTC = 0x00 ;             //send 00 to port C to set text home add lower
     data_w() ;
     PORTC = 0x10 ;            //send 10 to port C to set text home add upper
     data_w() ;
     PORTC = 0x40 ;            //text home add set command
     command_w() ;
    
     //text area set   
     PORTC = 0x1E ;            //no. of text area = 30 colums
     data_w() ;
     PORTC = 0x00 ;
     data_w() ;
     PORTC = 0x41 ;            //text area set cmd
     command_w() ;
             
    }                    
    
void main(void)
{
 unsigned char st = 0x00, gp = 0x00 ;                   //stat, b ;
 init_devices();
 
 Reset_on ;                       //Hardware LCD reset
 Delay_L() ;                     //Delay >=1ms
 Reset_off ;                    //Set reset back to high
 //Status_chk() ;
 
 LCD_init() ;
 
 PORTF = 0x04 ;                 //turns on status LED to indicate initialisation
                                   //complete
 Delay_L() ;
 //port_init() ;
 //PORTF = 0x02 ;
 
/* do
 {
 st = Status_return() ;
 gp = st & 0x03 ;
 }
 while (gp != 0x03) ;
 PORTF = st ;
 */
 PORTC = 0x90 ;                   //ensure cursor is off
 command_w() ;

 //Delay_L() ;
 //Status_chk() ;
 
 do
 {
 st = Status_return() ;
 gp = st & 0x03 ;
 }
 while (gp != 0x03) ;
 PORTF = st ;
 
 PORTC = 0x93 ;             //turn cursor on and blink
 command_w() ;
 Delay_L() ;
 //reset ;
 
 
 PORTC = 0x01 ;                      //to set cursor position
 data_w() ;
 PORTC = 0x01 ;
 data_w() ;
 PORTC = 0x21 ;
 command_w() ;
 
 PORTC = 0x00 ;                //8 line width cursor
 data_w() ;
 PORTC = 0x00 ;
 data_w() ;
 PORTC = 0xA7 ;
 command_w() ;
 
 do
 {
 st = Status_return() ;
 gp = st & 0x03 ;
 }
 while (gp != 0x03) ;
 PORTF = st ;
 

}


These final status checks are to get the status back and display it on some led's i have hooked up - that is all.
If someone could help i would be eternally gratefull.... :D

NOTE: if anyone wants a picture of the layout i can provide that - just ask


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2003 14:13 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
Toshiba T6963C controller with DMF-50773NY-LY (big girl)
Optrex dmf-5005 ny/ly/ake

Do you two know each other ? Just that you both are using the same Mega128 at 8 MHz, same compiler and your code is very similar. Well the displays are different. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2003 4:14 
Offline

Joined: Wed Mar 26, 2003 5:58
Posts: 2
yes we do know eachother - but neither of us can find out why either of the screens are not working..........

it is reallly frustrating us


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2003 15:03 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
I posted some code that I've used to the other thread. It's easier for me to post code that I know working than look through your code. ;) But it should be the same thing basically.

Some things that came to my mind while looking at your code:
-init could be checked to make sure everything is right
-are you sure that the compiler doesn't optimize the delay loop away ?
-you could try without busy flag checking and use delay instead - after that works add busy flag checking


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2003 4:03 
Offline

Joined: Wed Mar 26, 2003 5:58
Posts: 2
yeah thanx i have it up and running now. :D
Problem now is that it is not behaving in 6x8 graphics mode.
It will not allow me to set the no. of columns independant of the pixel mode 6x8 or 8x8.

Any ideas as to what this could be....?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2003 4:04 
Offline

Joined: Wed Mar 26, 2003 5:58
Posts: 2
yeah thanx i have it up and running now. :D
Problem now is that it is not behaving in 6x8 graphics mode.
It will not allow me to set the no. of columns independant of the pixel mode 6x8 or 8x8.

Any ideas as to what this could be....?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2003 4:04 
Offline

Joined: Wed Mar 26, 2003 5:58
Posts: 2
yeah thanx i have it up and running now. :D
Problem now is that it is not behaving in 6x8 graphics mode.
It will not allow me to set the no. of columns independant of the pixel mode 6x8 or 8x8.

Any ideas as to what this could be....?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2003 6:00 
Offline

Joined: Wed Mar 26, 2003 5:58
Posts: 2
i would really appreciate it if someone has a RAM MAP for the large LCD of this series DMF-50773NY LY
It seems as though my graphs are writing into my text ram area and stuffing things up....

Thank you
:!:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2003 6:01 
Offline

Joined: Wed Mar 26, 2003 5:58
Posts: 2
i would really appreciate it if someone has a RAM MAP for the large LCD of this series DMF-50773NY LY
It seems as though my graphs are writing into my text ram area and stuffing things up....

Thank you
:!:


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 21 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