3

I am working on a project which requires to interface TFT display with ILI9325 driver. I have successfully initialized the display but I am not able to rotate the display. Please suggest me the register and value to inserted in that to set the display in portrait or landscape mode.

Here is my LCD initialization code.

void LCD_ILI9325_Init(void)
{
unsigned char i;
    unsigned int f;

    LCD_Port_Init();

    LCD_REST_L;  //??
    _delay_ms(50);
    LCD_REST_H;
    _delay_ms(50);


    LCD_WriteReg(0x0001,0x0000);//зеркально вертикаль (0x0100) 
    LCD_WriteReg(0x0002,0x0700); 
    LCD_WriteReg(0x0003,0x1030);//преобразования RGB в GBR, строчной развертки 


    LCD_WriteReg(0x0004,0x0000);//зеркально вертикаль (0x0000) 
    LCD_WriteReg(0x0008,0x0207);  
    LCD_WriteReg(0x0009,0x0000);
    LCD_WriteReg(0x000A,0x0000); 
    LCD_WriteReg(0x000C,0x0000); 
    LCD_WriteReg(0x000D,0x0000);
    LCD_WriteReg(0x000F,0x0000);

    //power on sequence VGHVGL
    //Питания на последовательности VGHVGL
    LCD_WriteReg(0x0010,0x0000);   
    LCD_WriteReg(0x0011,0x0007);  
    LCD_WriteReg(0x0012,0x0000);  
    LCD_WriteReg(0x0013,0x0000);

    //vgh 
    LCD_WriteReg(0x0010,0x1290);   
    LCD_WriteReg(0x0011,0x0227);

    //vregiout 
    LCD_WriteReg(0x0012,0x001d);//0x001b

    //vom amplitude
    // По амплитуде 
    LCD_WriteReg(0x0013,0x1500);

    //vom H
    LCD_WriteReg(0x0029,0x0018); 
    LCD_WriteReg(0x002B,0x000D); 

    //gamma
    // Диапазон 
    LCD_WriteReg(0x0030,0x0004);
    LCD_WriteReg(0x0031,0x0307);
    LCD_WriteReg(0x0032,0x0002);//0006
    LCD_WriteReg(0x0035,0x0206);
    LCD_WriteReg(0x0036,0x0408);
    LCD_WriteReg(0x0037,0x0507); 
    LCD_WriteReg(0x0038,0x0204);//0200
    LCD_WriteReg(0x0039,0x0707); 
    LCD_WriteReg(0x003C,0x0405);//0504
    LCD_WriteReg(0x003D,0x0F02); 

    //ram
    LCD_WriteReg(0x0050,0x0000); 
    LCD_WriteReg(0x0051,0x00EF);
    LCD_WriteReg(0x0052,0x0000); 
    LCD_WriteReg(0x0053,0x013F);  
    LCD_WriteReg(0x0060,0x2700);//зеркально горизонталь (0xA700) 
    LCD_WriteReg(0x0061,0x0001); 
    LCD_WriteReg(0x006A,0x0000); 

    //
    LCD_WriteReg(0x0080,0x0000); 
    LCD_WriteReg(0x0081,0x0000); 
    LCD_WriteReg(0x0082,0x0000); 
    LCD_WriteReg(0x0083,0x0000); 
    LCD_WriteReg(0x0084,0x0000); 
    LCD_WriteReg(0x0085,0x0000); 

    //
    LCD_WriteReg(0x0090,0x0010); 
    LCD_WriteReg(0x0092,0x0600); 
    LCD_WriteReg(0x0093,0x0003); 
    LCD_WriteReg(0x0095,0x0110); 
    LCD_WriteReg(0x0097,0x0000); 
    LCD_WriteReg(0x0098,0x0000);
    LCD_WriteReg(0x0007,0x0133);


    LCD_WriteComand(0x0022);//Start to write to display RAM

    //paint screen black
    for(i=0;i<2;i++)
    {
        for(f=0;f<38400;f++)
        {
            LCD_WriteData(WHITE);
        }
    }
}

Please suggest me what to update in this code to rotate the display.

Thank You

Paul R
  • 208,748
  • 37
  • 389
  • 560
Ravi Kumar
  • 49
  • 6
  • looking at [the datasheet](http://www.hpinfotech.ro/ILI9325.pdf) you have to configure `register 01h` (`Driver Output Control 1`) and `register 03h` (`Entry Mode`) and `register 60h` (`Driver Output Control 2`) with correct values. – LPs Oct 05 '16 at 09:36
  • @LPs would you please help me to get those correct values. – Ravi Kumar Oct 05 '16 at 09:51
  • Take a look at [this code](http://www.avrfreaks.net/comment/1637336#comment-1637336) – LPs Oct 05 '16 at 10:04
  • @LPs Thanks for your help. By this code I am able to rotate the display in portrait mode only,when I try to turn the orientation in landscape mode the screen goes blank. It is not accepting the values as instructed in the link. In normal portrait mode values are `LCD_WriteReg(0x0001,0x0000);` `LCD_WriteReg(0x0003,0x1028);` `LCD_WriteReg(0x0060,0x2700);` portrait reverse `LCD_WriteReg(0x0001,0x0100);` `LCD_WriteReg(0x0003,0x1030);` `LCD_WriteReg(0x0060,0xA700);` It is not accepting values for landscape mode. – Ravi Kumar Oct 05 '16 at 10:56
  • Try changing landscape register 3 to `LCD_WriteReg(0x0003,0x1038)` – LPs Oct 05 '16 at 13:46
  • @LPs I tried to change the values but it didn't work. I would really appreciate if you tell me the values to put in these registers to rotate display in all four directions. Thanks – Ravi Kumar Oct 06 '16 at 05:32
  • 1
    It is always an hard matter to make those kind of devices works correctly. Many times the workflow has to be in a specific order. I haven't got the device. Try to study the datasheet and test values on the device directly. – LPs Oct 06 '16 at 06:09

1 Answers1

0

Without understanding how this LCD works you will not be able to solve your problem. First of all I recommend reading any hardware documentation carefully. There are always some interesting information in it. I know it sounds like a waste of time, but it never is.

o o o o o o o 
o o o o o o o
o o o o o o o
o o o o o o o
      ^
      |
  LCD DRIVER  < - > LCD RAM
      ^
      |
    input

The LCD driver controls two things:

1) how your input data is stored in LCD RAM

2) how your input data stored in LCD RAM is transfered to individual pixels

Let's start from this section of the ILI9325 LCD documentation:

7.2.3. Driver Output Control (R01h) on page 52

It clearly says, that this register controls the ILI9325 internal driver. However it does not affect the way your input data is stored in LCD RAM by the driver.

When SS = 0, the shift direction of outputs is from S1 to S720

When SS = 1, the shift direction of outputs is from S720 to S1

(page 11):

S720~S1 O(utput) LCD

Source output voltage signals applied to liquid crystal. To change the shift direction of signal outputs, use the SS bit. SS = “0”, the data in the RAM address “h00000” is output from S1. SS = “1”, the data in the RAM address “h00000” is output from S720. S1, S4, S7, … display red (R), S2, S5, S8, ... display green (G), and S3, S6, S9, ... display blue (B) (SS = 0).

This register only controls how contents of the LCD RAM are connected to the LCD pixels. It clearly says that DIRECTION OF OUTPUTS FROM THE DRIVER changes. The driver is capable of reversing your image by just changing SS setting in this register from 0 to 1. Please read more about it in the documentation, because you also need to adjust RGB settings.

If you want to change the way your input data is stored in LCD RAM take a look at the following section:

7.2.5. Entry Mode (R03h) on page 54

This register allows you to control HOW YOUR INPUT IS STORED IN LCD RAM. On page 55 you have details of how to adjust the driver for horizontal and vertical modes:

Horizontal: AM = 0, I/D[1:0] = 11

Vertical: AM = 1, I/D[1:0] = 10

I would say, that if you want to solve your problem do not change settings of R01h and R03h at the same time. As soon as you have your data displayed, change settings of R01h and see what the driver does. But do not change your input data, because once you start messing with R03h your data in LCD RAM will be in other RAM locations. Do not mix these two things together.

In addition bear in mind, that if you change the direction of storing your data in LCD RAM, lines become columns and vice versa. Take a closer look - page 55 describes it well. I think your software needs to be aware, that resolution is changed from 320x240 to 240x320 (rows become columns and vice versa).

q74
  • 88
  • 8