Spark Logic

[SOLVED] ILI9341 STM32 Blue pill

ILI9341 MSP3223 · 14-contact header Pinout

Hi all,

I apologise for this but i am new to STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog and I’ve been trying to get the display working for 3 days now with no joy. I am obviously missing something simple. I understand there is plenty of previous posts out there on here but after reading all them through im still no further forward.

I am using the graphics test code and i’m recieving the data back through the serial port correctly so the board has programmed correctly.

My code is;

#include "SPI.h"
#include "Adafruit_GFX_AS.h"
#include "Adafruit_ILI9341_STM.h"
// For the Adafruit shield, these are the default.
#define TFT_DC PA15
#define TFT_CS PB4
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
//Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
void setup() {
Serial.begin(9600);
Serial.println("ILI9341 Test!");
tft.begin();
// read diagnostics (optional but can help debug problems)
uint8_t x = tft.readcommand8(ILI9341_RDMODE);
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDMADCTL);
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDPIXFMT);
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDIMGFMT);
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDSELFDIAG);
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);

Serial.println(F("Benchmark Time (microseconds)"));

Serial.print(F("Screen fill "));
Serial.println(testFillScreen());
delay(500);

Replies16

Thu May 31, 2018 8:28 pm

Go on. I would guess you have a Red SPI ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog 3.3V display. With or without an XPT2046XPT2046Displays, touch panels and LEDs… pm Go on. I would guess you have a Red SPI ILI9341 3.3V display. With or without an XPT2046 touch controller. These boards must have the RST pin pulled high or under program cont…View in hardware catalog touch controller.

These boards must have the RST pin pulled high or under program control.

Add a 10k pullup. Or connect the RST pin to a GPIO pin as nature intended.
Note that Adafruit often omit the RST pin in the examples’ constructors. Their hardware has pullups. They know that the Red boards do not have pullups.

David.

Thu May 31, 2018 8:40 pm

Try to use a different pins for TFT_CS and _DC, for example
#define TFT_DC PA0
#define TFT_CS PA1

Thu May 31, 2018 8:43 pm

Hi David,

Thanks for your reply.

Yep that’s the exact one

I have tried various different libraries, configurations, etc…
I have had this display working on an Uno previously.

I have just connected the reset pin there high with a pull up resistor but still no joy?!

Thu May 31, 2018 8:51 pm

Thank God for that!!!

Thanks!

After changing the CS and DC it is working.

Can you give me an explanation why those pins I had been using wouldn’t work?

Thu May 31, 2018 8:53 pm

Because the PB4, PA15 and few others are used for JTAG under special conditions.
How did you program the BluePill?
With ST_link??

Thu May 31, 2018 8:58 pm

With an FTDIFTDICommunications, navigation, interfaces and RFID…something like: while true; do openocd -f /usr/local/share/openocd/scripts/interface/ ftdi /ch340.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg ; sleep 1;done I’m tr…View in hardware catalog usb to serial adapter.

Ok, so will I be able to use these pins still when using the display?

Thu May 31, 2018 8:59 pm

My god it is quick compared to the Uno :shock:

I’m now in love!!!!

Thu May 31, 2018 9:01 pm

You have uploaded your sketch to the BluePill via FTDIFTDICommunications, navigation, interfaces and RFID…something like: while true; do openocd -f /usr/local/share/openocd/scripts/interface/ ftdi /ch340.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg ; sleep 1;done I’m tr…View in hardware catalog Serial?
That means Serial method?

Thu May 31, 2018 9:07 pm

Connected to PA9 and PA10

Thu May 31, 2018 9:08 pm

I am asking you on the upload method, not interface..
You can upload your sketch via:
1. stm32duino bootloader (USB)
2. Serial (for example the FTDIFTDICommunications, navigation, interfaces and RFID…something like: while true; do openocd -f /usr/local/share/openocd/scripts/interface/ ftdi /ch340.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg ; sleep 1;done I’m tr…View in hardware catalog )
3. Jlink (JTAG)
4. ST_Link (SWD)
5. Black Magic ProbeBlack Magic ProbeModules, instruments and finished devices…_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER menu.upload_method.BMPMethod=BMP ( Black Magic Probe ) menu.upload_method.BMPMethod.upload.protocol=gdb_bmp menu.upload_method.B…View in hardware catalog
Which one did you use?

Thu May 31, 2018 9:11 pm

Ah sorry my misunderstanding,

Yeah FTDIFTDICommunications, navigation, interfaces and RFID…something like: while true; do openocd -f /usr/local/share/openocd/scripts/interface/ ftdi /ch340.cfg -f /usr/local/share/openocd/scripts/target/stm32f1x.cfg ; sleep 1;done I’m tr…View in hardware catalog serial Rx Tx

Thu May 31, 2018 9:17 pm

Ok, so will I be able to use these pins still when using the display?
Those PB4, PA15.. pins will work as GPIO when the stm32duino’s bootloader is used, afaik.
Otherwise you have to mess with remapping like
afio_cfg_debug_ports(AFIO_DEBUG_NONE);

Thu May 31, 2018 9:20 pm

Ok, thanks.

I should be ok for pins on this project. I only have maybe 2 encoders to add so that’s 4 more pins and then maybe the touch screen if I can manage to get that working.

Do you know off the top of your head what pins I can or can’t use for the encoder A and B inputs?

Thu May 31, 2018 9:28 pm

When using stm32duino bootloader – any.
Use pullups with encoders.
With the special case, afaik, some pins are used as JTAG, and JTAG needs to be disabled therefore (see the function call above).
Try to call the function in your setup() and assign PB4 and PA15 back – you will see.
The affected pins are PB3, PB4, PA15, PA12, PA11 afaik.
I do not know what is the latest status on this – ask our core experts.

Btw, reading the forum, wiki, searching in this forum and g…ling helps too..

Thu May 31, 2018 9:38 pm

Will the internal pull ups work ok?

I will have to have a look at using the bootloader. It sounds like it is a lot easier to use.

Thank you for your help. I was about ready to have a tantrum :lol:

Post a reply

Optional · up to 10 MiB