Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need LCD Help

Status
Not open for further replies.

AtomSoft

Well-Known Member
Im working on ARM7 but it nothing different really. The LCD code im having having issues with.

I need help initializing it. I got it working sort of. The only colors i see are Blue and green color.

I cant get White or Black to show or anything. I have sample code but it doesnt work really.

The Driver IC is HX8310-A

This is the sample code i found and edited to fit my layout. The code values themselves are unchanged...
Code:
//-------------------------------------------------------
//      Setup register values after power-on 
//-------------------------------------------------------
void powerSetup()
{
    // Power-On setup  (page 128, HX8310-A Datasheet)

    set_reg(0x00, 0x0001); // Restart the oscilator
    Delay_MS(10);

    // --mark1--
    // DTE = "0", D1-0 = "00", GON = "0"
    set_reg(0x07, 0x0000); 
    // PON = "0"
    set_reg(0x0d, 0x0000); 
    // VCOMG = "0"
    set_reg(0x0e, 0x0000); 

    // --1ms or more from mark1
    // --mark2--
    Delay_MS(10);
    // --10ms or more from mark2

    //              (Assume VCI = 3V)
    // Set VC2-0    (VC="001" -> REGP := 0.92 x VCI = 0.92 x 3 = 2.76V)
    set_reg(0x0c, 0x0001); 
    // Set VRH3-0   (VRH="0100" -> VGAM1OUT := 1.75 x REGP = 4.83V)
    // PON = "0"
    set_reg(0x0d, 0x0004);  // PON=0, VHR=04h, VDH=VciOUT*1.75 = 4.638V

    // Set VCM4-0, VDV4-0       // VDV=VDH*1.17=5.4264V, VcomH2=VDH*0.98=4.5452V
    set_reg(0x0e, 0x341e);  // VCOMG=1, VDV=14h, VCM=1Eh, (VDH=VGAM1OUT)
                                   
    // DK = "1", Set DC12-10
    set_reg(0x09, 0x000c);  // SAP="100", DC1x="000", DK="1"

    // BT2-0 = "000", Set DC02-00, AP2-0
    set_reg(0x03, 0x0010);  // BT=000b, DC=000b, AP=100b, SLP=0, STB=0

    // PON="1"
    set_reg(0x0d, 0x0014);  // PON=1, VRH=04h
    // set_reg(0x0d, 0x061b);  // PON=1, VRH=0Bh

    // --mark3--
    Delay_MS(20);
    Delay_MS(20);
    // --40ms from mark3

    //  Set BT 2-0
    // DK = "0"
    set_reg(0x09, 0x0004);  // SAP="100", DC1x="000", DK="0"
    // VCOMG = "1"
    set_reg(0x0e, 0x341e);  // VCOMG=1, VDV=14h, VCM=1Eh, (VDH=VGAM1OUT)


    // Do other mode settings here, as needed.
    // ...

    Delay_MS(20);
    Delay_MS(20);
    Delay_MS(20);
    // --100ms from mark3

    // Set SAP2-0   // (Display ON sequence)
    set_reg(0x09, 0x0004);  // SAP="100", DC1x="000", DK="0"

    // DTE = "1", D1-0 = "11", GON = "1"
    set_reg(0x07, 0x0033); 
}

//-------------------------------------------------------
//      Setup chip parameters
//-------------------------------------------------------
void chipSetup()
{
    // Chip setup
    // Screen direction: GS=1 => Bottom-Up, GS=0 =>Top-Down

  // R01:  0000 0 SM GS SS 000 nl4..nl0
  //    SS = LCD source driver output shift direction
  //    GS = LCD gate   driver output shift direction
  //    SM = Scan order of gate driver

#ifdef GUI_PORTRAIT
    //Portrait
#ifdef GUI_UPSIDEDOWN
    set_reg(0x01, 0x0313);  // SS=1, GS=1, NL=13h (160 lines)
#else
    set_reg(0x01, 0x0113);  // SS=1, GS=0, NL=13h (160 lines)
#endif
#else
    //Landscape
#ifdef GUI_UPSIDEDOWN
    set_reg(0x01, 0x0113);  // SS=1, GS=0, NL=13h (160 lines)
#else
    set_reg(0x01, 0x0313);  // SS=1, GS=1, NL=13h (160 lines)
#endif
#endif

    set_reg(0x02, 0x0700);  // FLD=01, B/C=1, EOR=1, NW=00h

    //...........................................................
    // R05: Entry Mode:   000 BGR  00 HVM 0  00 ID1 ID0  AM 000
    //  BGR = BGR - reverse (18) RGB bit order from MPU
    //  HVM = HighSpeedset_reg =1 = four words written to RAM at a time
    //  ID = after-set_reg: ID=1 = increment, ID=0 = decrement
    //  AM = set_reg: 1=vert 0=horiz

#ifdef GUI_PORTRAIT
    //Portrait
    set_reg(0x05, 0x0030);  // HWM=0, I/D=11b, AM=0, LG=000b

#else
    //Landscape
    //set_reg(0x05, 0x0030);  // HWM=0, I/D=11b, AM=0, LG=000b
    set_reg(0x05, 0x0038);  // HWM=0, I/D=11b, AM=1, LG=000b
    //set_reg(0x05, 0x0018);  // HWM=0, I/D=01b, AM=1, LG=000b
    //set_reg(0x05, 0x0028);  // HWM=0, I/D=10b, AM=1, LG=000b
#endif

    //...........................................................
    set_reg(0x06, 0x0000);  // CP=000h
    set_reg(0x0b, 0x0000);  // N0=00b, STD=00b, EQ=00b, DIV=00b, RTN=0000b
    set_reg(0x0f, 0x0000);  // SCN=0000b

    set_reg(0x11, 0x0000);  // VL=00h
    set_reg(0x14, 0x9f00);  // SE1=9Fh, SS1=00h
    set_reg(0x15, 0x9f00);  // SE2=..h, SS2=00h  <-- user defined
    set_reg(0x16, 0x7f00);  // HEA=7Fh, HSA=00h
    set_reg(0x17, 0x9f00);  // VEA=9Fh, VSA=00h

    Delay_MS(20000);

    // Gamma setting
    set_reg(0x30, 0x0000);  // 
    set_reg(0x31, 0x0605);  // 
    set_reg(0x32, 0x0407);  // 
    set_reg(0x33, 0x0104);  // 
    set_reg(0x34, 0x0203);  // 
    set_reg(0x35, 0x0303);  // 
    set_reg(0x36, 0x0707);  // 
    set_reg(0x37, 0x0300);  // 
    set_reg(0x3f, 0x0000);  // 
}

//===============================================================
//      GuiDevice interface implementation
//===============================================================



//-------------------------------------------------------
//      Turn on the display
//-------------------------------------------------------
int displayOn()
{
    // Display on  (page 126, HX8310-A Datasheet)
    //lcdState = LCD_BUSY;

//  Should we Set AP2-0 ?
//    set_reg(0x03, 0x0010);  // BT=000b, DC=000b, AP=100b, SLP=0, STB=0

    // Set SAP2-0  
    set_reg(0x09, 0x0004);  // SAP="100", (DC1x="000", DK="0")

    // GON = "0", DTE = "0", D1-0 = "01"
    set_reg(0x07, 0x0005);  // GON=0 DTE=0, REV=1, D=01b
    Delay_MS(20);  // wait 40ms (2 frames)
    Delay_MS(20);

    // GON = "1", DTE = "0", D1-0 = "01"
    set_reg(0x07, 0x0025);  // GON=1 DTE=0, REV=1, D=01b
    Delay_MS(20);  // wait 40ms (2 frames)
    Delay_MS(20);

    // GON = "1", DTE = "0", D1-0 = "11"
    set_reg(0x07, 0x0027);  // GON=1 DTE=0, REV=1, D=11b
    Delay_MS(20);  // wait 40ms (2 frames)
    Delay_MS(20);

    // GON = "1", DTE = "1", D1-0 = "11"
    set_reg(0x07, 0x0033);  // GON=1 DTE=1, REV=1, D=11b
    Delay_MS(20);  // wait 40ms (2 frames)
    Delay_MS(20);

    //lcdState = LCD_DISPLAY_ON;
    return 1;
}


//-------------------------------------------------------
//      Power on the device
//-------------------------------------------------------
int powerOn(){
    //lcdState = LCD_BUSY;

    // Make sure the power is on
    //TOSH_SET_LDVCC_PIN();
    //TOSH_SET_LDVCI_PIN();

    //lcdBkLtOn = 1;

    // Reset and init
    Delay_MS(10);   // optional wait
    reset();
    Delay_MS(10);
    powerSetup();
    Delay_MS(20);
    Delay_MS(20);
    chipSetup();

    set_reg(0x21, 0x0000);  // 

//...
// RAM set_reg
//    set_reg(0x22, 0x0000);  
//    Delay_MS(10000);
//...

    displayOn();

    //lcdState = LCD_ON;
//    signal GuiDevice.initDone();
    return 1;
}
int reset(){

    //lcdState = LCD_BUSY;

    //>>>Profiling A: A..A = 0us
    // Init control lines
    IO0SET = CS;    // deselect LCD
    IO0SET = RD;    // disable reading
    IO0SET = WR;    // disable writing
    IO0SET = RS;    // disable command

    IO0SET = RESET;
    Delay_MS(1);  // optional wait

    // Reset
    //>>>Profiling B: A..B = 2.5us
    IO0CLR = RESET;
    Delay_MS(1);
    IO0SET = RESET;
    Delay_MS(10);

    //lcdState = LCD_RESET;
    return 1;
}
 
I've seen all sorts of strange graphical issues when trying to bring up displays. Most issues I've seen were related to driving things too quickly between the IC and the display. You'll need to verify that you've set the porch timings correctly, hsync, vsync, pxlclk, overall timings etc. At least that's where I would start.
 
Awesome! Is the driver IC on the LCD or on your board? If it is on your board, here is some code that will help verify that your databus is connected properly:

Code:
for (x = 0; x < 255; x++)
{
	SetColor( RGB565CONVERT( x, 0, 0 ) );
	Bar( 0, x, 79, x );
	SetColor( RGB565CONVERT( 0, x, 0 ) );
	Bar( 80, x, 159, x );
	SetColor( RGB565CONVERT( 0, 0, x ) );
	Bar( 160, x, 239, x );
}

This will create three gradients on the display; red, green, and blue. The display I use is 5 bits for red and blue and 6 bits for green. If my display is soldered properly, I'll see 32 distinct colors of red and blue and 64 distinct colors of green. This will immediately identify many (most?) soldering issues for the display.

**broken link removed**
It appears that my camera is a little sensitive to green! And the slightly dark stripe across the display at the bottom of the gradient is due to a line on my LCD screen protector
 
Last edited:
Sweet! :) Graphic stuff is a lot of fun, it's my favorite type or project to work on. It can be very frustrating to get the LCD working sometimes, but once it is up and running I find it enjoyable to work on.
 
One thing that would be nice (you probably thought about it) is to bee abel to jog thru the images while wathcing them.

But I think its realy nice. Good work
 
Status
Not open for further replies.

Latest threads

Back
Top