ILI9806 Graphical Issue - Page 1
Forum section: electronics / general

author: maurosmartins
author_rank: Regular Contributor
timestamp: December 30, 2022, 11:32:50 am
content: 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: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)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;u8LetterHeight = u8Font;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 - ' ') * u8NumberOfBytesPerLetter) + 3;//3 = u8LetterWidth + u8LetterHeight + u8LetterOccupiedWidthu8LetterOccupiedWidth = 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 rowsfor(k=0; k<8; k++){//inside the rows of each bytefor(i=0; i<u8LetterOccupiedWidth; i++){//each columnu16LetterByteIndex = u16LetterIndex + j + i*u8LetterHeightInBytes;if( u8Font & (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;}}//ifWR_RESET();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();WR_SET();}//for i}//for k}//for jCS_SET();}//for L}//PPrintlooking forward your reply,Best regards, Mauro.

author: eutectique
author_rank: Frequent Contributor
timestamp: December 30, 2022, 12:28:12 pm
content: When you step through your function with a debugger, do you notice some unexpected values of variables?

author: maurosmartins
author_rank: Regular Contributor
timestamp: December 30, 2022, 02:17:50 pm
content: 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.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:so I'm biased to think there is some isse with the TFT driver that I'm not aware of.Best regards, Mauro.

author: eutectique
author_rank: Frequent Contributor
timestamp: December 30, 2022, 02:37:53 pm
content: 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 stripesYou get the idea.

author: mon2
author_rank: Frequent Contributor
timestamp: December 30, 2022, 02:45:46 pm
content: Perhaps compare your init code to this one:https://github.com/birdtechstep/fbtft/blob/master/fb_ili9806.c

author: darkspr1te
author_rank: Frequent Contributor
timestamp: December 30, 2022, 03:45:40 pm
content: QuoteI looked at my code for ili9xxx based screens and normally isCode:CS_RESET();CS_SET();vWrite16BitCommand(0x2C);//Memory Write (2Ch);CS_RESET();DC_DATA();here is the code from a simlar libCode:void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue){/* Write 16-bit Index, then Write Reg */ClrCsLCD_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 */ClrCsLCD_REG = LCD_RegValue;SetCs}hope this helpsdarkspr1te

author: maurosmartins
author_rank: Regular Contributor
timestamp: January 01, 2023, 11:32:30 am
content: Dear all,thank you for your repliesQuote from: eutectique on December 30, 2022, 02:37:53 pmI've tested this, 2px wide works perfectly:I get strange results when I set stripe to 1 pxcan 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...Quote from: mon2 on December 30, 2022, 02:45:46 pmI've tried this also, using the parameters on the link unfortunately I don't see anything on the display.Quote from: darkspr1te on December 30, 2022, 03:45:40 pmchecking 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.