8 Bit TFT Library Issue

Working libraries, libraries being ported and related hardware
stevestrong
Posts: 317
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 7
Location: Munich, Germany
Contact:

Re: 8 Bit TFT Library Issue

Post by stevestrong »

I am not sure that the TFT library is wrong, I rather suspect the core, something at the initialization it may go wrong if you enable USB serial but you do not use it.
But I cannot help you there due to not available knowledge, sorry.

User avatar
fpiSTM
Posts: 754
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 28
Location: Le Mans
Contact:

Re: 8 Bit TFT Library Issue

Post by fpiSTM »

I did not check all the code anyway did you enabled all the required GPIO clock ?

mkengineering
Posts: 10
Joined: Thu Apr 30, 2020 8:35 pm

Re: 8 Bit TFT Library Issue

Post by mkengineering »

fpiSTM wrote:
Mon Aug 24, 2020 8:51 am
I did not check all the code anyway did you enabled all the required GPIO clock ?
Ahh! That makes much more sense now. I didn't enable the GPIOA / GPIOB clocks in the APB2ENR register anywhere in my code, causing the display not to init properly. When Serial is enabled, it must init APB2 (also used by USART1) somewhere else. Thanks for the help guys! I modified my the reset function to init APB2 for GPIOA and GPIOB according to the following table from the datasheet and it now works as intended:

Image

Modified reset:

Code: Select all

void Adafruit_TFTLCD_8bit_STM32::reset(void)
{
	RCC->APB2ENR |= 0b1100; //set bits 3 and 4 for GPIOA and GPIOB
	pinMode(TFT_RD, OUTPUT);
	pinMode(TFT_WR, OUTPUT);
	pinMode(TFT_RS, OUTPUT);
	pinMode(TFT_CS, OUTPUT);
	CS_IDLE; // Set all control bits to HIGH (idle)
	CD_DATA; // Signals are ACTIVE LOW
	WR_IDLE;
	RD_IDLE;
	//set up 8 bit parallel port to write mode.
	setWriteDir();

	// toggle RST low to reset
	if (TFT_RST > 0) {
		pinMode(TFT_RST, OUTPUT);
		digitalWrite(TFT_RST, HIGH);
		delay(100);
		digitalWrite(TFT_RST, LOW);
		delay(100);
		digitalWrite(TFT_RST, HIGH);
		delay(100);
	}
}
Is there a cleaner way to do this? It works but would need to be changed if a different GPIO port was used (as modified in the header).

User avatar
fpiSTM
Posts: 754
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 28
Location: Le Mans
Contact:

Re: 8 Bit TFT Library Issue

Post by fpiSTM »

Well pinMode set the clock of the GPIO pin port.

As it calls this function to set the GPIO port clock:
https://github.com/stm32duino/Arduino_C ... c#L67-L152

mkengineering
Posts: 10
Joined: Thu Apr 30, 2020 8:35 pm

Re: 8 Bit TFT Library Issue

Post by mkengineering »

Thanks for the help on this guys!
Here's the final version of my ILI9486 library for STM32duino.
https://github.com/mkengineering/STM32_ILI9486_8_bit
I also ported over some popular examples for the Adafruit TFTs.

Ollie
Posts: 4
Joined: Wed Mar 18, 2020 4:46 am

Re: 8 Bit TFT Library Issue

Post by Ollie »

I like your efficient programming style. Efficient usage of resources, avoidance of the bloatware, and proper level of documentation and naming conventions are hall marks of long term experience. Well done 8-)

Post Reply

Return to “Libraries & Hardware”