I apologise for this but i am new to stm32 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);
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.
#define TFT_DC PA0
#define TFT_CS PA1
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?!
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?
How did you program the BluePill?
With ST_link??
Ok, so will I be able to use these pins still when using the display?
I’m now in love!!!!
That means Serial method?
You can upload your sketch via:
1. stm32duino bootloader (USB)
2. Serial (for example the FTDI)
3. Jlink (JTAG)
4. ST_Link (SWD)
5. Black Magic Probe
Which one did you use?
Yeah FTDI serial Rx Tx
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);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?
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..
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 ![]()


