Page 1 of 1

ILI9341 display not working with STM32 core

Posted: Sat Feb 25, 2023 2:33 am
by w8bh
I am using a Blue Pill board (128K) with an ILI9341 display, running the Adafruit graphicstest example. It works great using Roger's core. However, when I switch to the official STM32 core, the display looks like it does not initialize (it stays white).

From trying other examples, I see that the code compiles and uploads. It's just the display that doesn't initialize.

My software environment: Libraries (Adafruit_GFX, Adafruit_ILI9341) are the latest versions. Arduino IDE 1.8.19. I've tried STM32 board versions 2.0.0 through 2.4.0. IDE Board options under the STM32 core are "Generic STM32F1 series -> BluePill F103CB (or C8 with 128K). I use STLINK/STM32CubeProgrammer(SWD) to upload the code.

Does anyone know why this well-known example works under Roger's core but not the current STM32 core?

Re: ILI9341 display not working with STM32 core

Posted: Sat Feb 25, 2023 4:32 am
by fpiSTM

Re: ILI9341 display not working with STM32 core

Posted: Sat Feb 25, 2023 2:01 pm
by w8bh
Thank you for your suggestion and link. The display initialization procedure requires 2 pins for device control and chip select, which in my case are A0 and A1. I use constants PA0 and PA1 for these. I also tried PIN_A0 and PIN_A1. Neither work. Should I be referring to these pins in a different way?

Re: ILI9341 display not working with STM32 core

Posted: Sat Feb 25, 2023 3:58 pm
by ag123
I've not visited this in a while, I've made a fork of it sometime back.
https://github.com/ag88/Adafruit_ILI9341_SPI_stm32duino
viewtopic.php?t=896
viewtopic.php?t=895

note that I've not tested it on a stm32f103c8, and that it has been a while since the last update, tested against a 2.0 core, but things has changed then. hence, things may break.

another thing is about the lcd reset pin (not reset for the mcu), the lcd reset pin needs to be driven by a gpio pin and it needs to reset the lcd during initialization. Apparently, that makes a non responsive ILI9341 lcd respond. I think that has something to do with the SPI speeds, only by triggering the (hardware) LCD reset, can the LCD resync with the fast SPI clocks and work correctly. 'soft' (i.e. reset by command) won't work as I'd guess the command will be garbled and hence no reset is done.

Re: ILI9341 display not working with STM32 core

Posted: Sun Feb 26, 2023 1:53 pm
by fpiSTM
w8bh wrote: Sat Feb 25, 2023 2:01 pm Thank you for your suggestion and link. The display initialization procedure requires 2 pins for device control and chip select, which in my case are A0 and A1. I use constants PA0 and PA1 for these. I also tried PIN_A0 and PIN_A1. Neither work. Should I be referring to these pins in a different way?
If you use 20 for PA1 (D20) and 21 for PA1 (D21), it should works, at least you will not have the issue linked to int8_t usage of Adafruit library.

Re: ILI9341 display not working with STM32 core

Posted: Sun Feb 26, 2023 10:46 pm
by w8bh
Thank you fpiSTM!! You were correct.

I dusted off my oscilloscope to discover that the Adafruit library left the DC line floating. The floating DC line caused all sorts of issues: the display would work for a few seconds at most, and would work with some power supplies but not others, etc. When I changed the DC definition from PIN_A1 to 21, the DC pin output was normal and the display was rock solid. I would have never solved this issue without your help.

Re: ILI9341 display not working with STM32 core

Posted: Mon Feb 27, 2023 8:38 am
by fpiSTM
So this is the issue which should be fixed by my PR on Adafruit.