LCDInfo.com

http://www.lcdinfo.com
It is currently Mon Nov 25, 2024 4:17

All times are UTC + 2 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Thu Oct 12, 2006 8:20 
Offline

Joined: Tue Oct 10, 2006 8:40
Posts: 8
My previous note may have been unclear.

Using the Sparkfun supplied Nokia 6100 knockoff LCD and Epson controller chip, I have a board I spun that has a switching power supply oscialltion issue. I can supply backlight power (6.8V) OR 3.3V digital / display power to the unit. But not both at the same time currently.

I have a C8051F410 processor attached on the same 3.3V supply. It goes into la-la land when the 6.8V is tunred on. I'll fix that, but in the meantime....

If the LCD is supplied 3.3V to digital / display power, it should here my 9bit serial commands, correct? Should I be able to see text regardless of backlight (provided I got my contrast correct), or is that backlight power necessary for other undocumented reasons?

Thanks,
Matt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 8:34 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
Yes you can see something even without the backlight. Your cellphone doesn't keep its backlight burning all the time does it not. :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 16:36 
Offline

Joined: Tue Oct 10, 2006 8:40
Posts: 8
Yes, I knew I was asking for the slap in the face answer :)

I was expecting that I should be able to see something with all the bit twiddling I'm doing. Is there a chance that I don't have the volume / contrast controls setup right and that I just am not seeing it? When the display is being run only on 3.3V, how much current is it pulling? I also worry that I have a dead LCD and am just beating my head against an unpowered wall...

Thanks Zee,
Matt


Code:
void InitLCD(void)
{
   long j;
   CS = 1;

   slow_wait_25ms (40);
   SCK = 1;
   MOSI = 0;
   CS = 0;
   LCDRESET = 0;
   slow_wait_25ms (40);

    LCDRESET = 1;
   //    ctl_timeout_wait(ctl_get_current_time() + 50);
   slow_wait_25ms (40);
    SendLcd(LCDCommand,DISCTL);  // display control
    SendLcd(LCDData,0x03); //00
    SendLcd(LCDData,0x20); //20
    SendLcd(LCDData,0x0C); //0A
    SendLcd(LCDData,0x00); //None for other
    SendLcd(LCDCommand,NOP);  // Data Sheet recomends you send this from time to time

    SendLcd(LCDCommand,COMSCN);        //
    SendLcd(LCDData,0x01);             // Scan 1-80
   
    SendLcd(LCDCommand,OSCON);         //
   
    SendLcd(LCDCommand,SLPOUT);        // Sleep out command (must be done before DISPON)
   

   //   ctl_timeout_wait(ctl_get_current_time() + 100);         // data sheet says to wait 100ms here
   slow_wait_25ms (40);

    SendLcd(LCDCommand,VOLCTR);  // electronic volume, this is kinda contrast/brightness
    SendLcd(LCDData,0xff);//ff      // change this to get brighter or darker start point then use volup/down to adjust
    SendLcd(LCDData,0x01);

    SendLcd(LCDCommand,PWRCTR);                             // power ctrl
    SendLcd(LCDData,0x0f);                                  //everything on

   //
   ////   ctl_timeout_wait(ctl_get_current_time() + 100);         // data sheet says to wait 100ms here
   slow_wait_25ms (40);

    SendLcd(LCDCommand,DISINV);

   //    SendLcd(LCDCommand,TMPGRD);  // Temp Gradient
   //    SendLcd(LCDData,0x01);


    SendLcd(LCDCommand, DATCTL);   // Data Control
    SendLcd(LCDData, 0x00);   // normal orientation; scan across cols, then rows
    SendLcd(LCDData, 0x00);   // RGB arrangement (RGB all rows/cols)
//   WriteCommand(lctData, 0x04);   // RGB arrangement (RGB row 1, BGR row 2)
    SendLcd(LCDData, 0x01);   // 8-color display
//   WriteCommand(lctData, 0x02);   // 16-color display
    SendLcd(LCDData, 0x00);   //
//    LCD_Set_Resolution(LOW_RES);

    SendLcd(LCDCommand,RGBSET8);   // setup color lookup table
// Setup the color lookup table by choosing evenly spaced color values
// for a nice even spread. Blue only has 2 bits, so the spacing is wider
// but still spans 0x00 - 0x0f
// Bit organisation is RRRGGGBB

    SendLcd(LCDCommand,RGBSET8);         
    SendLcd(LCDData,0x00);                // RED
    SendLcd(LCDData,0x02);
    SendLcd(LCDData,0x04);
    SendLcd(LCDData,0x06);
    SendLcd(LCDData,0x08);
    SendLcd(LCDData,0x0a);
    SendLcd(LCDData,0x0c);
    SendLcd(LCDData,0x0f);
    SendLcd(LCDData,0x00);                // GREEN
    SendLcd(LCDData,0x02);
    SendLcd(LCDData,0x04);
    SendLcd(LCDData,0x06);
    SendLcd(LCDData,0x08);
    SendLcd(LCDData,0x0a);
    SendLcd(LCDData,0x0c);
    SendLcd(LCDData,0x0f);
    SendLcd(LCDData,0x00);                // BLUE
    SendLcd(LCDData,0x04);
    SendLcd(LCDData,0x09);
    SendLcd(LCDData,0x0f);

    SendLcd(LCDCommand,NOP);                                // Data Sheet recomends you send this from time to time

   
    SendLcd(LCDCommand,PASET);   // page start/end ram
     SendLcd(LCDData,0x02);       // for some reason starts at 2
     SendLcd(LCDData,0x83);       
    SendLcd(LCDCommand,CASET);   // column start/end ram
     SendLcd(LCDData,0x00);       // for some reason starts at 2
     SendLcd(LCDData,0x83);       // for some reason starts at 2



    SendLcd(LCDCommand,RAMWR);   // write some stuff (background)
 
  for (j = 0; j < 18000; j++){
     SendLcd(LCDData,0x1C); //28 = 0x1C = green
  }
    SendLcd(LCDCommand, DISON);                             // Turn Display ON

    for (j = 0; j < 160; j++){   // this loop adjusts the contrast, change the number of iterations to get
    SendLcd(LCDCommand, VOLUP);             // desired contrast.  This might be different for individual LCDs
   slow_wait_25ms (4);
 }







}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 19:17 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
This is the initialization procedure I'm successfully using with my LCD.

Code:
   WriteCommand(COMSCN);
   WriteData(0x01);
   WriteCommand(OSCON);
   WriteCommand(SLPOUT);
   WriteCommand(PWRCTR);
   WriteData(0x0f);
   WriteCommand(DISINV);
   WriteCommand(DATCTL);
   WriteData(0x01);
   WriteData(0x01);
   WriteData(0x02);
   WriteCommand(RGBSET8);
   WriteData(0x00);   // R
   WriteData(0x02);   // R
   WriteData(0x04);   // R
   WriteData(0x06);   // R
   WriteData(0x08);   // R
   WriteData(0x0a);   // R
   WriteData(0x0c);   // R
   WriteData(0x0e);   // R
   WriteData(0x00);   // G
   WriteData(0x02);   // G
   WriteData(0x04);   // G
   WriteData(0x06);   // G
   WriteData(0x08);   // G
   WriteData(0x0a);   // G
   WriteData(0x0c);   // G
   WriteData(0x0e);   // G
   WriteData(0x00);   // B
   WriteData(0x04);   // B
   WriteData(0x08);   // B
   WriteData(0x0c);   // B
   WriteCommand(DISON);


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 0:03 
Offline

Joined: Tue Oct 10, 2006 8:40
Posts: 8
Thanks Zee. I'll try that tonight.

What would you suggest is the simplest pixel put or demonstrator that would display a dot or something else?

Also, is there any chance that all my screwing around could've written something to memory on the LCD that is in conflict with other commands? If so, is there some kind of master reset that resets the LCD to factory defaults?

Thanks again,
Matt


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 16:29 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
Very simple plot for the 8-bit mode. Does something visible in the 16-bit mode too but doesn't look correct.

Code:
void Plot(int X, int Y, int COLOR)
{
   if ((X>-1) && (X<132) && (Y>-1) && (Y<132))
   {
      WriteCommand(CASET);
      WriteData(X);
//      WriteData(X+1);
      WriteCommand(PASET);
      WriteData(Y);
//      WriteData(Y+1);
      WriteCommand(RAMWR);
      WriteData(COLOR);
   }
}


I use the hardware reset line to reset the display. Other than that the most problems besides incorrect initialization/command sequence comes from the contrast calibration which varies from display to display. My both (Epson & Philips) displays work just fine without touching any contrast adjustments.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 20:32 
Offline

Joined: Tue Oct 10, 2006 8:40
Posts: 8
Thanks again Zee.

I'm now doubting my SPI bit bang stuff, as I've seen conflicting code that people claims works versus the datasheet. It looks like reset low == off, reset high == on. Chip Select low == device enabled, CS high == device disabled.

After a command or data sequence, do you toggle the CS from low to high, then back to low? The datasheet seems to indicate this, but not too many people show this in code.

You refer in your post to using the hardware reset:

Quote:
I use the hardware reset line to reset the display....


Do you program the unit once, then subsquently use the reset switch only, or do you re-initialize the LCD everytime you power your setup on?

The datasheet also indicates that to be nice you should turn the display off to let some capacitors bleed down before powering down using PWRCTRL. Do you do this or is is just a little bit of motherhood?

Thanks again for all your help Zee...
Matt


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 21:47 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
My "chain of command" in my source seems to be:

After powerup:
Code:
   SetPortVal(CONTROL, CL_LO | SD_LO | RES_LO | CS_HI, 1);
   Delay(40000);
   SetPortVal(CONTROL, CL_LO | SD_LO | RES_HI | CS_HI, 1);
   SetPortVal(CONTROL, CL_LO | SD_LO | RES_HI | CS_LO, 1);


Then the initialization and after that whatever I want to do.

My writeroutines are:
Code:
void WriteCommand(unsigned char Data)
{
   int count;

   SetPortVal(CONTROL, CL_LO | SD_LO | RES_HI | CS_LO, 1);
   SetPortVal(CONTROL, CL_HI | SD_LO | RES_HI | CS_LO, 1);

   for (count=7; count>-1; count--)
   {
      if (Data >> count & 1)
      {
         SetPortVal(CONTROL, CL_LO | SD_HI | RES_HI | CS_LO, 1);
         SetPortVal(CONTROL, CL_HI | SD_HI | RES_HI | CS_LO, 1);
      }
      else
      {
         SetPortVal(CONTROL, CL_LO | SD_LO | RES_HI | CS_LO, 1);
         SetPortVal(CONTROL, CL_HI | SD_LO | RES_HI | CS_LO, 1);
      }
   }
}

void WriteData(unsigned char Data)
{
   int count;

   SetPortVal(CONTROL, CL_LO | SD_HI | RES_HI | CS_LO, 1);
   SetPortVal(CONTROL, CL_HI | SD_HI | RES_HI | CS_LO, 1);

   for (count=7; count>-1; count--)
   {
      if (Data >> count & 1)
      {
         SetPortVal(CONTROL, CL_LO | SD_HI | RES_HI | CS_LO, 1);
         SetPortVal(CONTROL, CL_HI | SD_HI | RES_HI | CS_LO, 1);
      }
      else
      {
         SetPortVal(CONTROL, CL_LO | SD_LO | RES_HI | CS_LO, 1);
         SetPortVal(CONTROL, CL_HI | SD_LO | RES_HI | CS_LO, 1);
      }
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 22:04 
Offline

Joined: Tue Oct 10, 2006 8:40
Posts: 8
Ah ha! Going step by step thru yours has forced me to realize that a macro I was using was set to one, but not setting the clock on that specific cycle! I'll BET it'll work tonight when I get back to my setup.
THANKS ZEE!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 5:34 
Offline

Joined: Tue Oct 10, 2006 8:40
Posts: 8
Zee...update...it was something different than I thought, but still a SW bug on my side. LCD is up and running, making pretty colors and boxes. Font mapping is next. Thanks again for all your help...
Matt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 10:39 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
Where the pictures?-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 5:35 
Offline

Joined: Tue Oct 10, 2006 8:40
Posts: 8
Gotta go to Germany for a week and change. I'll post the pretty stuff (fonts, et. al) when I get back along with my code for anyone else that wants to borrow...


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

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 4 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