Page 2 of 2

Re: 8 Bit TFT Library Issue

Posted: Sat Aug 22, 2020 11:26 am
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.

Re: 8 Bit TFT Library Issue

Posted: Mon Aug 24, 2020 8:51 am
by fpiSTM
I did not check all the code anyway did you enabled all the required GPIO clock ?

Re: 8 Bit TFT Library Issue

Posted: Mon Aug 24, 2020 3:40 pm
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).

Re: 8 Bit TFT Library Issue

Posted: Mon Aug 24, 2020 3:57 pm
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

Re: 8 Bit TFT Library Issue

Posted: Tue Sep 08, 2020 12:50 am
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.

Re: 8 Bit TFT Library Issue

Posted: Sun Sep 13, 2020 3:08 am
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-)