How get starting with stm32f103c8(Blue Pill) connect 3.5inch tft lcd

I have stm32f103c8(Blue Pill) connected with 3.5inch tft lcd mcufriend TouchScreen, like this

TFT STM32F103
LCD_RST – PB7
LCD_CS – PB6
LCD_RS – PB5
LCD_WR – PB4
CD_RD – PB3
LCD_D0 – PA0
LCD_D1 – PA1
LCD_D2 – PA2
LCD_D3 – PA3
LCD_D4 – PA4
LCD_D5 – PA5
LCD_D6 – PA6
LCD_D7 – PA7
3.3V – 3.3V
GND – GND

But I don’t know how starting programming
Could help me
Thank you very much

Connect your display like this:

//LCD pins  |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST| |SD_SS|SD_DI|SD_DO|SD_SCK|
//STM32 pin |PA7|PA6|PA5|PA4|PA3|PA2|PA1|PA0| |PB0|PB6|PB7|PB8|PB9| |PA15 |PB5  |PB4  |PB3   | **ALT-SPI1**

Install MCUFRIEND_kbv via IDE Library Manager.

The examples should run out of the box.

David.

Thank you ,I am going to try that :slight_smile:

Hello david_prentice
I chose TouchScreen_Calibr_native example but error message is ):

Arduino: 1.8.2 (Windows 7), Board: “Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)”

TouchScreen_Calibr_native:21: error: ‘A1’ was not declared in this scope

int XP = 6, YP = A1, XM = A2, YM = 7; //most common configuration

^

TouchScreen_Calibr_native:28: error: ‘XM’ was not declared in this scope

TouchScreen_kbv ts(XP, YP, XM, YM, 300); //re-initialised after diagnose

^

TouchScreen_Calibr_native:28: error: ‘YM’ was not declared in this scope

TouchScreen_kbv ts(XP, YP, XM, YM, 300); //re-initialised after diagnose

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘void readResistiveTouch()’:

TouchScreen_Calibr_native:45: error: ‘XM’ was not declared in this scope

pinMode(XM, OUTPUT);

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘char* Aval(int)’:

TouchScreen_Calibr_native:82: error: ‘A0’ was not declared in this scope

sprintf(buf[cnt], “A%d”, pin - A0);

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘boolean diagnose_pins()’:

TouchScreen_Calibr_native:103: error: ‘A0’ was not declared in this scope

for (i = A0; i < A5; i++) pinMode(i, INPUT_PULLUP);

^

TouchScreen_Calibr_native:103: error: ‘A5’ was not declared in this scope

for (i = A0; i < A5; i++) pinMode(i, INPUT_PULLUP);

^

TouchScreen_Calibr_native:105: error: ‘A0’ was not declared in this scope

for (i = A0; i < A4; i++) {

^

TouchScreen_Calibr_native:105: error: ‘A4’ was not declared in this scope

for (i = A0; i < A4; i++) {

^

TouchScreen_Calibr_native:132: error: ‘XM’ was not declared in this scope

XM = Apins[!idx]; XP = Dpins[!idx]; YP = Apins[idx]; YM = Dpins[idx];

^

TouchScreen_Calibr_native:132: error: ‘YM’ was not declared in this scope

XM = Apins[!idx]; XP = Dpins[!idx]; YP = Apins[idx]; YM = Dpins[idx];

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘void report()’:

TouchScreen_Calibr_native:318: error: ‘XM’ was not declared in this scope

XP, XM - A0, YP - A0, YM, TS_WID, TS_HT, tft.readID());

^

TouchScreen_Calibr_native:318: error: ‘A0’ was not declared in this scope

XP, XM - A0, YP - A0, YM, TS_WID, TS_HT, tft.readID());

^

TouchScreen_Calibr_native:318: error: ‘YM’ was not declared in this scope

XP, XM - A0, YP - A0, YM, TS_WID, TS_HT, tft.readID());

^

Multiple libraries were found for “MCUFRIEND_kbv.h”
Used: C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv
Not used: C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv-master
exit status 1
‘A1’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

What can i do for solve this error?

First off. Remove any multiple libraries.

Try the other examples before you try Touch.

Thank you (:
I will do this

Hello david_prentice
I chose graphictest_kbv example
But error message is :frowning:

Arduino: 1.8.2 (Windows 7), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)"

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv\examples\graphictest_kbv\graphictest_kbv.ino:16:54: fatal error: Adafruit_GFX.h: No such file or directory

#include "Adafruit_GFX.h"// Hardware-specific library

^

compilation terminated.

exit status 1
Error compiling for board Generic STM32F103C series.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

What solve for this error?

You should install Adafruit_GFX via the IDE Library Manager

Thank you very much (:
I chose readpixel_kbv , graphictest_kbv and drawBitmap_kbv examples is worked good

But when I chose TouchScreen_Calibr_native But message error is

Arduino: 1.8.2 (Windows 7), Board: “Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)”

Build options changed, rebuilding all
TouchScreen_Calibr_native:21: error: ‘A1’ was not declared in this scope

int XP = 6, YP = A1, XM = A2, YM = 7; //most common configuration

^

TouchScreen_Calibr_native:28: error: ‘XM’ was not declared in this scope

TouchScreen_kbv ts(XP, YP, XM, YM, 300); //re-initialised after diagnose

^

TouchScreen_Calibr_native:28: error: ‘YM’ was not declared in this scope

TouchScreen_kbv ts(XP, YP, XM, YM, 300); //re-initialised after diagnose

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘void readResistiveTouch()’:

TouchScreen_Calibr_native:40: error: ‘XM’ was not declared in this scope

pinMode(XM, OUTPUT);

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘char* Aval(int)’:

TouchScreen_Calibr_native:77: error: ‘A0’ was not declared in this scope

sprintf(buf[cnt], “A%d”, pin - A0);

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘boolean diagnose_pins()’:

TouchScreen_Calibr_native:98: error: ‘A0’ was not declared in this scope

for (i = A0; i < A5; i++) pinMode(i, INPUT_PULLUP);

^

TouchScreen_Calibr_native:98: error: ‘A5’ was not declared in this scope

for (i = A0; i < A5; i++) pinMode(i, INPUT_PULLUP);

^

TouchScreen_Calibr_native:100: error: ‘A0’ was not declared in this scope

for (i = A0; i < A4; i++) {

^

TouchScreen_Calibr_native:100: error: ‘A4’ was not declared in this scope

for (i = A0; i < A4; i++) {

^

TouchScreen_Calibr_native:127: error: ‘XM’ was not declared in this scope

XM = Apins[!idx]; XP = Dpins[!idx]; YP = Apins[idx]; YM = Dpins[idx];

^

TouchScreen_Calibr_native:127: error: ‘YM’ was not declared in this scope

XM = Apins[!idx]; XP = Dpins[!idx]; YP = Apins[idx]; YM = Dpins[idx];

^

C:\Users\JSY\Documents\Arduino\libraries\MCUFRIEND_kbv\examples\TouchScreen_Calibr_native\TouchScreen_Calibr_native.ino: In function ‘void report()’:

TouchScreen_Calibr_native:312: error: ‘XM’ was not declared in this scope

XP, XM - A0, YP - A0, YM, TS_WID, TS_HT, tft.readID());

^

TouchScreen_Calibr_native:312: error: ‘A0’ was not declared in this scope

XP, XM - A0, YP - A0, YM, TS_WID, TS_HT, tft.readID());

^

TouchScreen_Calibr_native:312: error: ‘YM’ was not declared in this scope

XP, XM - A0, YP - A0, YM, TS_WID, TS_HT, tft.readID());

^

exit status 1
‘A1’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

How i can solve this ?

Just force the Touchpins e.g. Edit. Corrected the BLUEPILL pins

//int XP = 6, YP = A1, XM = A2, YM = 7;  //most common configuration
int XP = PB7, XM=PA6, YP=PA7, YM=PB6; //BLUEPILL

It sounds as if you are using the "Roger Clark" Core.
Roger Clark does not "know" A0, A4, A5. So just invent dummy defines

It is much wiser to use the Official Core from STMicroelectronics. They make the STM32 chips.
You can install it via the IDE Boards Manager.

David.

Hello Mr.david_prentice
I change in TouchScreen_Calibr_native example like this

//int XP = 6, YP = A1, XM = A2, YM = 7; //most common configuration
int XP = PA6, YP = PB6, XM = PB7, YM = PA7; //to match your BluePill

and invent a value for A0=1 , A4=4 , A5=5

But I don't see anything on my screen just this message

#define NUMSAMPLES 3 in libraray
use a stylus or something similar to touch as close to the center of the highlighted crosshair as possible. keep as still as possible and keep holding until th highlight is removed. Repeat for all crosshairs in sequence .
Report can be pasted from Serial
Touch screen to continue

Can you help me?

My apologies. I wrote the wrong "default" pins. It should be:

int XP=PB7,XM=PA6,YP=PA7,YM=PB6; //BLUEPILL

I strongly recommend that you use the official ST Microelectronics Core.

David.

Hello david_prentice
thank you for help me :slight_smile:
I could touch my screen But now see this message

To use the new calibration settings you must map
the values from point p= ts.getPoint() e.g.
x=map(p.x, LEFT, RT, 0, tft.width());
y=map(p.y, TOP, BOT, 0, tft.height());
swap p.x and p.y if diff ORIENTATION

MCUFRIEND_kbv ID=0x6814 320x480

PORTRAIT CALIBRATION 320x480
x= map(p.x, LEFT=125, RT=727, 0, 320);
y= map(p.y, TOP=78, BOT=918, 0, 480);

Touch Pin Wiring XP=23 XM=A6 YP=A7 YM=22

LANDSCAPE CALIBRATION 480x320
x= map(p.y, LEFT=78, RT=918, 0, 480)
y=map(p.y, TOP=727, BOT=125, 0, 320)

Now what should I do? where should I do this edit in the code?

Look at my examples. Copy-paste your values. The example should work.
These are typical lines for a screen that I tested on a BluePill.

const int XP=PB7,XM=PA6,YP=PA7,YM=PB6; //0x1520 BLUEPILL
const int TS_LEFT = 122, TS_RT = 899, TS_TOP = 922, TS_BOT = 148;

If I paste them into Button_Simple or Touch_Shield_new the programs will work for MY screen.

YOUR screen is different. You should copy-paste YOUR values from the Serial Terminal.

Is your Serial Terminal working?

Have you installed the official ST Core? e.g. from the IDE Boards Manager
Or are you using the weird RogerClark Core?

David.

hello david_prentice

Is your Serial Terminal working?
yes,it is working

I copy my values from the Serial Terminal monitor and I past them into Button_Simple or Touch_Shield_new but message error is

Arduino: 1.8.2 (Windows 7), Board: “Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial, 72Mhz (Normal), Smallest (default)”

Build options changed, rebuilding all
C:\Users\JSY\AppData\Local\Temp\arduino_modified_sketch_737438\Touch_shield_new.ino:9:25: fatal error: TouchScreen.h: No such file or directory

#include <TouchScreen.h>

^

compilation terminated.

exit status 1
Error compiling for board Generic STM32F103C series.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

Have you installed the official ST Core? e.g. from the IDE Boards Manager
Or are you using the weird RogerClark Core?
I don’t know but my STM like this

Your Tutorial link shows an elderly v1.8.2 IDE
And an elderly "RogerClark" type Maple Core.

If you use an up to date IDE, the Board Manager will install/update the official ST Core.
And the IDE will install/update any libraries e.g. Adafruit_TouchScreen.h

Most BluePills actually have 128kB Flash memory.

All the same, I tested a BluePill with the RogerClark Core.
The Calibration sketch works (with some dummy A0, A4, A5 defines)

I strongly recommend that you use the ST Core.

David.

Hello david_prentice
I search about my stm32f103c8t6(blue pill) and found it have core CORTIX M3 ARM .
What do you advise me ?
if I use an up to date IDE, will my screen work?

If you use any IDE it will work. But only in those countries where Ohms Law is valid.

stm32f103c8t6 is CORTEX M3 ARM

Hello
I am sorry Mr.David
But I don't understand mean the ST Core.
you mean library or board ?

Tools->Board->Boards Manager->STM32 Cores by STMicroelectronics version v1.8.0