Author Topic: ILI9806 Graphical Issue  (Read 1098 times)

0 Members and 1 Guest are viewing this topic.

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
ILI9806 Graphical Issue
« on: December 30, 2022, 11:32:50 am »
Hello all,

recently I've playing with a 800x480 TFT display using the ILI9806 driver.

so far I've managed to initialize it and write to it, nevertheless I'm getting very strange results and I wonder if someone has seen this before.

The letters on the image are all in the same color but sometimes the color changes and the letters lose definition. I'm excluding errors on the letter printing function because I've already used it successfully on the past.

I have similar problems sending "icons" consisting of only one background color and one icon color:

1676185-0

Could it have to due with some timing issues?


here is the function I've written for printing the letters in case it helps, not very clean because I've been making a lot of tests:
Code: (c) [Select]
void vPPrint(char text[], uint16_t x, uint16_t y, const uint8_t u8Font[], uint16_t FontColor, uint16_t BgColor){
  volatile uint16_t l;
  volatile uint16_t texlength;
  volatile uint16_t u8LetterWidth, u8LetterHeight, u8LetterHeightInBytes, u8NumberOfBytesPerLetter, u8LetterOccupiedWidth;
  volatile uint16_t i, j, k, u16LetterIndex, u16LetterByteIndex;
  uint16_t lastColor;

  u8LetterWidth = u8Font[0];
  u8LetterHeight = u8Font[1];

  u8LetterHeightInBytes = (u8LetterHeight/8.0) + ((u8LetterHeight%8 == 0) ? 0: 1);

  u8NumberOfBytesPerLetter = u8LetterWidth * u8LetterHeightInBytes + 1;

  texlength=strlen(text);

  for(l=0;l<texlength;l++){

delay_us(10);

    u16LetterIndex = ( (text[l] - ' ') * u8NumberOfBytesPerLetter) + 3;//3 = u8LetterWidth + u8LetterHeight + u8LetterOccupiedWidth

    u8LetterOccupiedWidth = u8Font[u16LetterIndex-1];

    setWindowAddress(x, y, x+u8LetterOccupiedWidth-1, y+u8LetterHeight);


CS_RESET();
vWrite16BitCommand(0x2C);//Memory Write (2Ch)
CS_SET();

DC_DATA();

CS_RESET();

    x+=u8LetterOccupiedWidth;

    lastColor = FontColor;

    for(j=0; j<u8LetterHeightInBytes; j++){//each byte has 8 rows
      for(k=0; k<8; k++){//inside the rows of each byte

        for(i=0; i<u8LetterOccupiedWidth; i++){//each column

          u16LetterByteIndex = u16LetterIndex + j + i*u8LetterHeightInBytes;

          if( u8Font[u16LetterByteIndex] & (0b00000001<<k) ){
          TFTBUSPORT_GPIO_Port->ODR = FontColor;
          if(lastColor != FontColor){
          delay_us(40);
          lastColor = FontColor;
          }
          } else{
  TFTBUSPORT_GPIO_Port->ODR = BgColor;
if(lastColor != BgColor){
delay_us(40);
lastColor = BgColor;
}

          }//if

WR_RESET();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
WR_SET();


        }//for i
      }//for k
    }//for j

    CS_SET();

  }//for L
}//PPrint

looking forward your reply,
Best regards, Mauro.
 

Offline eutectique

  • Frequent Contributor
  • **
  • Posts: 453
  • Country: be
Re: ILI9806 Graphical Issue
« Reply #1 on: December 30, 2022, 12:28:12 pm »
When you step through your function with a debugger, do you notice some unexpected values of variables?
 

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
Re: ILI9806 Graphical Issue
« Reply #2 on: December 30, 2022, 02:17:50 pm »
Hello eutectique,

unfortunately I don't see strange values. Also, inspecting the BUS using a logic analyzer I see what is supposed.

Consider the following example where I'm only drawing the icon.

1676341-0

color a) and b) are the same in this case 0x4229, I'm only reading the 11LSB of the bus so this yields 0x229 for background and 0x7FF for trace color (white).

the logic analyzer shows the following packages:

1676347-1

so I'm biased to think there is some isse with the TFT driver that I'm not aware of.

Best regards, Mauro.
« Last Edit: December 30, 2022, 02:19:29 pm by maurosmartins »
 

Offline eutectique

  • Frequent Contributor
  • **
  • Posts: 453
  • Country: be
Re: ILI9806 Graphical Issue
« Reply #3 on: December 30, 2022, 02:37:53 pm »
To rule out hardware and timing issues, I would suggest to start with simple steps:
- fill the whole screen with one colour (cycle through colours white->grey->red->whatever)
- make sure it displays correctly all the colours you expect to see
- fill the screen with interleaving vertical stripes of 1px width, cycle the colours
- make the stripes 2px, 3px, etc
- the same for interleaving horizontal stripes

You get the idea.
 

Offline mon2

  • Frequent Contributor
  • **
  • Posts: 491
  • Country: ca
Re: ILI9806 Graphical Issue
« Reply #4 on: December 30, 2022, 02:45:46 pm »
Perhaps compare your init code to this one:

https://github.com/birdtechstep/fbtft/blob/master/fb_ili9806.c
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 366
  • Country: zm
Re: ILI9806 Graphical Issue
« Reply #5 on: December 30, 2022, 03:45:40 pm »
Quote
setWindowAddress(x, y, x+u8LetterOccupiedWidth-1, y+u8LetterHeight);


   CS_RESET();
   vWrite16BitCommand(0x2C);//Memory Write (2Ch)


   DC_DATA();

   CS_RESET();

I looked at my code for ili9xxx based screens and normally is
Code: [Select]
CS_RESET();
CS_SET();
vWrite16BitCommand(0x2C);//Memory Write (2Ch);
CS_RESET();
DC_DATA();
here is the code from a simlar lib

Code: [Select]
void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
{
  /* Write 16-bit Index, then Write Reg */
  ClrCs
  LCD_REG = LCD_Reg;
  /* Write 16-bit Reg */
  LCD_RAM = LCD_RegValue;
  SetCs
}


void LCD_WriteCommand(u16 LCD_RegValue)
{
  /* Write 16-bit Index, then Write Reg */
  ClrCs

  LCD_REG = LCD_RegValue;

  SetCs
}



hope this helps

darkspr1te
« Last Edit: December 30, 2022, 03:54:56 pm by darkspr1te »
 

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
Re: ILI9806 Graphical Issue
« Reply #6 on: January 01, 2023, 11:32:30 am »
Dear all,

thank you for your replies

To rule out hardware and timing issues, I would suggest to start with simple steps:
- fill the whole screen with one colour (cycle through colours white->grey->red->whatever)
- make sure it displays correctly all the colours you expect to see
- fill the screen with interleaving vertical stripes of 1px width, cycle the colours
- make the stripes 2px, 3px, etc
- the same for interleaving horizontal stripes

You get the idea.

I've tested this, 2px wide works perfectly:
1678027-0
 I get strange results when I set stripe to 1 px
1678021-1 
can you conclude anything from this result?

for the letter it may influence but the icons are bigger so I think it shouldn't make a difference.... just guessing...

Perhaps compare your init code to this one:

https://github.com/birdtechstep/fbtft/blob/master/fb_ili9806.c
I've tried this also, using the parameters on the link unfortunately I don't see anything on the display.

Quote
setWindowAddress(x, y, x+u8LetterOccupiedWidth-1, y+u8LetterHeight);


   CS_RESET();
   vWrite16BitCommand(0x2C);//Memory Write (2Ch)


   DC_DATA();

   CS_RESET();

I looked at my code for ili9xxx based screens and normally is
Code: [Select]
CS_RESET();
CS_SET();
vWrite16BitCommand(0x2C);//Memory Write (2Ch);
CS_RESET();
DC_DATA();
here is the code from a simlar lib

Code: [Select]
void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
{
  /* Write 16-bit Index, then Write Reg */
  ClrCs
  LCD_REG = LCD_Reg;
  /* Write 16-bit Reg */
  LCD_RAM = LCD_RegValue;
  SetCs
}


void LCD_WriteCommand(u16 LCD_RegValue)
{
  /* Write 16-bit Index, then Write Reg */
  ClrCs

  LCD_REG = LCD_RegValue;

  SetCs
}



hope this helps

darkspr1te


checking the code above I think it is odd to send a command with CS high, in desperation I've tested and indeed it doesn't work for me, nothing is sent to the display.

maybe the controller has some errata? unfortunately I don't know I can't even find documentation for 0xBC, 0xBD and 0xBE commands.

Best regards, Mauro.
« Last Edit: January 01, 2023, 05:46:40 pm by maurosmartins »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf