ST7735 tft with a Bluepill STM32F103C8T6

Post here first, or if you can't find a relevant section!
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by mrburnette »

fredbox wrote: Mon Jun 28, 2021 10:26 pm
My suggestion is that you try to get away from the prototype cables and weld everything with wires as short as possible on a perforated plate. Join strand by strand carefully, the arrangement you have it should work smoothly
An old fashioned wire-wrap tool makes a much better connection that Dupont pins. I've made thousands of connections with mine over the years.

A spool of multicolored wire makes keeping track of connections fairly easy.
+1
I like W-W, still use it from time to time, takes me back to the early 70's as a Burroughs FE ... always making backplane changes.

BUT, there is no reason that prototyping will not work IF you take a bit of care before every assembly:

- clean every Dupont jumper ends; they are tin/solder plated and oxidize
- test every jumper after cleaning, they should pass 500mA (DC current-limited supply works great)
- use a vacuum cleaner (shop vac) to really clean the prototyping board. 100% IPA may be required but beware adhesive-backed boards!

One of mine: https://hackster.imgix.net/uploads/atta ... 75&fit=min

... but after sitting in the basement lab for a few months, it too refused to "fire-up" ... pin-by-pin reinsertion of the jumpers bought it back to life... can't keep a good circuit down.

I strongly recommend committing permanent projects to PC board ASAP.
I also have a tab in every Arduino project titled "Notes.h" where I put all of the sketch wiring & crazy notes; it really does help as paper notes are soon lost unless one is diligent and keeps a true Engineer's notebook.

Code: Select all


// Software Pin Name  // GPIO: HSPI    VSPI           //  ILI9341 J2      // Notes: all HSPI pins can remap
// -------------------------------------------------- //    1 VDD 3.3V
// -------------------------------------------------- //    2 GND
#define HSP_CS                  15                    //    3 CS          <========== xSPI centric
#define VSP_CS                           5
#define HSP_RST    -1   //      27                    //    4 RST         <========== User Defined (Tie to VDD)
#define VSP_RST    -1   //              25
#define HSP_DC                  26                    //    5 D/C         <========== User Defined
#define VSP_DC                          16
#define HSP_MOSI                13                    //    6 SDI-MOSI    <========== xSPI centric
#define VSP_MOSI                        23      
#define HSP_SCLK                14                    //    7 SCK         <========== xSPI centric
#define VSP_SCLK                        18
// -------------------------------------------------- //    8 LED                     !!! 3.3V NOT 5V !!!
#define HSP_MISO    -1   //     12                    //    9 SDO-MISO    <========== xSPI centric (Not used ILI9341)
#define VSP_MISO    -1   //             19

ASCII art is really never outdated.

Code: Select all


**************************** ILI9341 320x240 DISPLAY LAYOUT ****************************
0,0
----------------------------------------------------------------------------> 319
| nnnT                                                                 DOW
|              lcd.fillRect( 0,  0, 319, 59, 0);     // blank top
|
|
|<- 059 
|
|              lcd.fillRect( 0, 60, 319, 114, 0);     // blank middle
|                              HH:MM:SS A
|
|
|
|<- 174
|              lcd.fillRect( 0, 175, 319, 64, 0);     // blank lower
|
| MON DD YYYY
|
|<- 239
*/

/*

ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by ag123 »

dupont pins do come lose rather easily, especially with rough handling and disconnecting / connecting often.
i've one where the 'app' is giving problems (with an ili9341 lcd), it turns out a pin is damaged and the wire broken left with a single thread.
in the end i resorted to changing the whole dupont wire bundle and it works normally again.
the attractiveness is they literally works like a breadboard and is possibly a lowest cost 'connector' compared to 'all the rest' on the likes of ebay / aliexpress etc. i think those JST XH types makes for a better connection, they are not so tall as well but cost a bit more.
this video from Andreas Spiess is an inspiration for working with dupont pins
https://www.youtube.com/watch?v=eI3fxTH6f6I
i tend to use shells to 'pre jumper' the pins in a particular way, this is so that the bundle can plug right in say on a blue pill on one side and the other straight into the lcd, it saves me the trouble of figuring out which pin goes to where.
TFTLCDCyg
Posts: 26
Joined: Tue Jan 07, 2020 9:50 pm
Answers: 1

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by TFTLCDCyg »

Don't get me wrong, I have nothing against such kind of wires, they do their job to allow us to test a new component or temporarily wire a some extra component to the project. But: and since we have everything ready, with a single thread that fails! ..., I already saw their faces, because I have been in that situation many times: it is frustrating to check all the wiring again to end up disassembling everything.

The SPI bus is very special, so it must be treated with care: short cables and good connections.

On the SPI 1: the ST7735 TFT, here also it is the wiring of the resistive touch screen that the TFT has.
On the SPI 2: the microSD reader, the library I used is the recent SdFat.

Code: Select all

SPI 1 TFT  ---   ST7735
CS1   ---   PA4
SCK   ---   PA5
MOSI  ---   PA7
MISO  ---   PA6
GND, 3V3
library: Adafruit ST7735 and ST7789, version=1.6.0
Adafruit GFX Library, version=1.7.5

Code: Select all

Touch panel
CS1   ---   PA2
PEN   ---   PA1
library: XPT2046_Touchscreen, version=1.3
https://github.com/PaulStoffregen/XPT2046_Touchscreen

Code: Select all

SPI 2    ---    microSD reader
CS    ---   PB12
SCK   ---   PB13
MOSI  ---   PB15
MISO  ---   PB14
GND, 3V3
library: SdFat, version=2.0.7
https://github.com/greiman/SdFat

Arduino IDE: 1.8.15
STM32 Core: 1.9.0 or 2.0.0
MCU: F103VET6 and F103ZET6 (M3 DEMO)
Programmer: ST-link V2

https://www.mediafire.com/view/r8tczadh3usv9gy
010gamer4life
Posts: 7
Joined: Tue Jun 22, 2021 6:20 pm

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by 010gamer4life »

I just finished making it on a PCB, and i checked all the connections and i have 0 wires that are longer then 3cm. But i still get a blank screen.

Here are my connections:

Code: Select all

TFT - STM32
GND - GND
VCC - 5V
SCL - PA5
SDA - PA7
RES - PA0
DC - PA1
CS - PA4
BL - 3.3V
The code i used:

Code: Select all


#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>

#define TFT_CS        PA4
#define TFT_RST       PA0
#define TFT_DC        PA1

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void) {
  Serial.begin(9600);
  Serial.print(F("Hello! ST77xx TFT Test"));

  tft.initR(INITR_BLACKTAB);
  //tft.initR(INITR_GREENTAB);

  Serial.println(F("Initialized"));

  tft.fillScreen(ST77XX_BLACK);
  testdrawtext("Gehello", ST77XX_WHITE);
  delay(1000);

  Serial.println("done");
  delay(1000);
}

void loop() {}

void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}
The serial monitor looks like this:
21:19:18.671 -> Hello! ST77xx TFT TestInitialized
21:19:20.662 -> done
I also tried this but had no succes:

Code: Select all

#define TFT_CS        PA4
#define TFT_DC        PA1
#define TFT_RST       PA0
#define TFT_MOSI      PA7
#define TFT_SCLK      PA5
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
Any idea what i got wrong? it worked once but never worked again, i tried a new STM32F103C8T6 and a new TFT ST7735 Display. When i plug it in all the lights go on and my display goes white.

Pictures:
https://ibb.co/TkNCLq5
https://ibb.co/WFmyw3V
https://ibb.co/98dnZX9
TFTLCDCyg
Posts: 26
Joined: Tue Jan 07, 2020 9:50 pm
Answers: 1

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by TFTLCDCyg »

I located an old project with a bluepill. I have taken on the task of soldering some wires to connect the ST7735 display.

https://www.mediafire.com/view/fup93qjus9j4pqm

After a few minutes ...

https://www.mediafire.com/view/uzqefqr8vdxevve

https://www.mediafire.com/view/bfyiwy7bjv7hytw

Somewhat messy the joints, I wanted to know if something different could be happening with the C8. After uploading the sketch ...

https://www.mediafire.com/view/77rw53yqyzgk7cv

There is no other choice: check pin to pin again
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by mrburnette »

Arduino_Adafruit_Ex.png
Arduino_Adafruit_Ex.png (66.86 KiB) Viewed 4164 times
OPINION: Always try a working example...


Pull the Adafruit Example for ST7735.

You (appear) to want to use HW SPI, try software SPI instead ... less demanding on timing. Adjust the pins to match the BluePill signals.

Code: Select all

// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
//#define TFT_MOSI 11  // Data out
//#define TFT_SCLK 13  // Clock out

// For ST7735-based displays, we will use this call
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

The snippet below is from an ILI9341 that I did years ago ... it uses a Maple Mini by BAITE and uses SPI for the ILI9341 TFT.

Code: Select all

#include "SPI.h"
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

// Pinout for Maple Mini
#define TFT_CS         13 // PB4                  
#define TFT_DC         12 // PA15                
#define TFT_RST        14 // PB3  

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); // Use hardware SPI

void setup() {
  Serial.begin(115200);
  tft.begin();
}

Here is the signaling for several uC's I used at the time:

Code: Select all

// ILI9341 TFT GLCD display connections for hardware SPI
// Signal           Maple Mini         Leonardo      LCD Display    UNO pins
//#define _sclk         6         //         15       J2 pin 7          13
//#define _miso         5 NC      //         14          pin 9          12
//#define _mosi         4         //         16          pin 6          11
#define TFT_CS         13         //         10          pin 3          10
#define TFT_DC         12         //          9          pin 5           9
#define TFT_RST        14         //          8          pin 4           8

// create lcd object
Adafruit_ILI9341 lcd = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); // Using hardware SPI
Bluepillpinout.jpg
Bluepillpinout.jpg (69.1 KiB) Viewed 4163 times
TFTLCDCyg
Posts: 26
Joined: Tue Jan 07, 2020 9:50 pm
Answers: 1

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by TFTLCDCyg »

I suspect it is the STM32 2.0.0 kernel. I thought I had version 2.0.0 installed but it is actually 1.9.0, I checked in the IDE preferences and the json link refers to the previous version:

https://github.com/stm32duino/BoardMana ... index.json

Here the ST7735 + F103C8 go very well.

When checking the MCU manager, I came across this:

https://www.mediafire.com/view/zb09njniwmuwy2w

I am going to remove the STM32 folder from the arduino packages folder (so as not to lose kernel 190) and install kernel 2.0.0, using this path:

https://github.com/stm32duino/BoardMana ... index.json

I verify the sketch with the new STM32 kernel. To cross your fingers...
TFTLCDCyg
Posts: 26
Joined: Tue Jan 07, 2020 9:50 pm
Answers: 1

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by TFTLCDCyg »

With kernel 2.0.0 we get ...

https://www.mediafire.com/view/9qtc443bj9a25yz

I tried both the previous libraries that worked (GFX and ST7735), as well as the most recent ones, and in both cases the same result. Perhaps some special issue with the handling of the SPI 1 or SPI 2 bus, is what causes the failure.

Try removing the 2.0.0 kernel first and then installing the 1.9.0 kernel, with this reference:

https://github.com/stm32duino/BoardMana ... index.json

I think the MCU F103C8 and the ST7735 display should work toghether rigth now.
heretop
Posts: 39
Joined: Sun Jun 20, 2021 2:09 pm

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by heretop »

TFTLCDCyg wrote: Wed Jun 30, 2021 3:52 pm With kernel 2.0.0 we get ...

https://www.mediafire.com/view/9qtc443bj9a25yz

I tried both the previous libraries that worked (GFX and ST7735), as well as the most recent ones, and in both cases the same result. Perhaps some special issue with the handling of the SPI 1 or SPI 2 bus, is what causes the failure.

Try removing the 2.0.0 kernel first and then installing the 1.9.0 kernel, with this reference:

https://github.com/stm32duino/BoardMana ... index.json

I think the MCU F103C8 and the ST7735 display should work toghether rigth now.
Thank you very much for the finding! My blackpill also does not work with ST7789 I have. I tried your method (revert my stm32duino to 1.9.0) and it works! It takes so long for me to debug this. I also bought a st link for this problem
010gamer4life
Posts: 7
Joined: Tue Jun 22, 2021 6:20 pm

Re: ST7735 tft with a Bluepill STM32F103C8T6

Post by 010gamer4life »

For anyone still encounering any problems :)

If you wish to use the STM32F01C8T6 (in my case) you will probobly need to revert your stm32duino to 1.9.0
step 1. put this link in your preferences under 'additional board manager urls 'https://raw.githubusercontent.com/stm32 ... index.json'
step 2. open board manager and install the deprecated 1.9.0 version of STM32 Cores
step 3. open Skecht -> Include library -> Manage libraries -> search for ST7735 -> download the ST7735/ST7789 adafruit library
step 4. open file -> example -> adafruit st7735 -> grapictest -> change the pinout the the code below
step 5. upload the same way you've been doing it with arduino IDE. GOODLUCK!

Code: Select all

 // For the breakout board, you can use any 2 or 3 pins.
 // These pins will also work for the 1.8" TFT shield.
 #define TFT_CS        PA4
 #define TFT_RST        PA0 // Or set to -1 and connect to Arduino RESET pin
 #define TFT_DC         PA1
 
Post Reply

Return to “General discussion”