Hello
i would try to control a TFT from MCUfriend it is with a spfd5408 controller.
With the libary from mcufriend it works perfect on the arduino uno. but when i use Adafruit_TFTLCD_8bit_STM32-master and the STM32 It doesnt work.
Can somebody help?
PS: It has no SPI only Parallel port
What library from MCUfriend ?
I am not aware of any "library" from mcufriend.com
MCUFRIEND_kbv library works fine with STM32F103C8T6 but you have to use the preferred "Adapter Shield" wiring.
If you want to use special wiring, you need to USE_SPECIAL
I have no connection with Adafruit_TFTLCD_8bit_STM32 and nor does Adafruit (as far as I know)
Note that the SPFD5408 is very similar to the ILI9320. Most hacked Adafruit libraries support ILI9325.
David.
The Libary is MCUFRIEND_kbv-master.
It is not compatible. If i choose the STM32 i got this error. Attention very long Error Code ![]()
Update: Error Code was too big i had to shorten
i had try the ili93xx but it doesnt work. And a little bit strange is with STM32 the HEX ID is 0x5804 and with arduino uno 0x5408
#error REGS group
^
C:\Users\Tim\Documents\Arduino\libraries\MCUFRIEND_kbv-master\MCUFRIEND_kbv.cpp: In member function 'void MCUFRIEND_kbv::reset()':
C:\Users\Tim\Documents\Arduino\libraries\MCUFRIEND_kbv-master\MCUFRIEND_kbv.cpp:73:17: error: 'setWriteDir' was not declared in this scope
setWriteDir();
^
In file included from C:\Users\Tim\Documents\Arduino\libraries\MCUFRIEND_kbv-master\MCUFRIEND_kbv.cpp:33:0:
C:\Users\Tim\Documents\Arduino\libraries\MCUFRIEND_kbv-master\utility/mcufriend_shield.h:691:40: error: 'RD_PIN' was not declared in this scope
#define RD_OUTPUT PIN_OUTPUT(RD_PORT, RD_PIN)
^
C:\Users\Tim\Documents\Arduino\libraries\MCUFRIEND_kbv-master\utility/mcufriend_shield.h:387:13: note: in definition of macro 'PIN_OUTPUT'
if (pin < 8) {GP_OUT(port, CRL, 0xF<<((pin)<<2));} \
Fehler beim Kompilieren für das Board Maple Mini.
Alright it is now compiling but where could i define the Pin output for D0-7 i cant find it in the .h or .cpp
As I explained earlier, you have to use the "preferred" wiring.
Copy-paste the actual build command from the Arduino IDE. Use Compile=verbose in File->Preferences.
I only want to see one g++ command line. i.e. with -I and -D arguments
Not reams of error messages.
David.
Edit. You must use the fixed wiring. If you want to use different wiring, you must #define all the pins in LCD_ID_readreg.ino to verify that your wiring works.
Then copy-paste the defines to your message. I will post the appropriate SPECIAL for you.
I useed now this Pin OUT but it doesn´t work
//-- Arduino UNO or Mega 2560 Plugged as shield
#define LCD_RST PB3
#define LCD_CS PB4
#define LCD_RS PB5
#define LCD_WR PB6
#define LCD_RD PB7
#define LCD_D0 PA0
#define LCD_D1 PA1
#define LCD_D2 PA2
#define LCD_D3 PA3
#define LCD_D4 PA4
#define LCD_D5 PA5
#define LCD_D6 PA6
#define LCD_D7 PA7
i got this message in the serial monitor
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)
reg(0x0000) C0 C0 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) C4 C4 C4 C4 Manufacturer ID
reg(0x0009) C9 C9 C9 C9 C9 Status Register
reg(0x000A) CA CA Get Power Mode
reg(0x000C) CC CC Get Pixel Format
reg(0x0061) E1 E1 RDID1 HX8347-G
reg(0x0062) E2 E2 RDID2 HX8347-G
reg(0x0063) E3 E3 RDID3 HX8347-G
reg(0x0064) E4 E4 RDID1 HX8347-A
reg(0x0065) E5 E5 RDID2 HX8347-A
reg(0x0066) E6 E6 RDID3 HX8347-A
reg(0x0067) E7 E7 RDID Himax HX8347-A
reg(0x0070) F0 F0 Panel Himax HX8347-A
reg(0x00A1) E1 E1 E1 E1 E1 RD_DDB SSD1963
reg(0x00B0) F0 F0 RGB Interface Signal Control
reg(0x00B4) F4 F4 Inversion Control
reg(0x00B6) F6 F6 F6 F6 F6 Display Control
reg(0x00B7) F7 F7 Entry Mode Set
reg(0x00BF) FF FF FF FF FF FF ILI9481, HX8357-B
reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0 Panel Control
reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA
reg(0x00CC) CC CC Panel Control
reg(0x00D0) D0 D0 D0 Power Control
reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
reg(0x00D4) D4 D4 D4 D4 Novatek ID
reg(0x00DA) DA DA RDID1
reg(0x00DB) DB DB RDID2
reg(0x00DC) DC DC RDID3
reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-P
reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 GAMMA-N
reg(0x00EF) EF EF EF EF EF EF ILI9327
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
reg(0x00F6) F6 F6 F6 F6 Interface Control
The "preferred" wiring is:
#elif defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_NUCLEO_F103C8) || defined(ARDUINO_BLUEPILL_F103C8)
#warning Uno Shield on BLUEPILL
#define RD_PORT GPIOB
//#define RD_PIN 5
#define RD_PIN 0 //hardware mod to Adapter. Allows use of PB5 for SD Card
#define WR_PORT GPIOB
#define WR_PIN 6
#define CD_PORT GPIOB
#define CD_PIN 7
#define CS_PORT GPIOB
#define CS_PIN 8
#define RESET_PORT GPIOB
#define RESET_PIN 9
Life would be much simpler if you just copied the preferred wiring. Then you don't have the complication of a SPECIAL.
I can post you the SPECIAL if there is a compelling reason for not using those control pins. (data is on PA0..PA7)
David.
Edit. This is crazy. Your wiring does NOT verify (from the message posted while I was typing). Try telling the truth.
i dont get it with the Pin out.
so on the STM32 isnt a PIN0 or does it mean pin0 on GPIOB so it is PB0?
And in my libary is this
#elif defined(USE_MY_BLUEPILL) && (defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_NUCLEO_F103C8))
#warning Uno Shield on MY BLUEPILL
#if defined(ARDUINO_NUCLEO_F103C8) //regular CMSIS libraries
#define REGS(x) x
#define GPIO_INIT() { RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_IOPDEN | RCC_APB2ENR_AFIOEN; \
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_1;}
#else //weird Maple libraries
#define REGS(x) regs->x
#endif
#define WRITE_DELAY { }
#define READ_DELAY { RD_ACTIVE; }
#define GROUP_MODE(port, reg, mask, val) {port->REGS(reg) = (port->REGS(reg) & ~(mask)) | ((mask)&(val)); }
#define GP_OUT(port, reg, mask) GROUP_MODE(port, reg, mask, 0x33333333)
#define GP_INP(port, reg, mask) GROUP_MODE(port, reg, mask, 0x44444444)
#define PIN_OUTPUT(port, pin) {\
if (pin < 8) {GP_OUT(port, CRL, 0xF<<((pin)<<2));} \
else {GP_OUT(port, CRH, 0xF<<((pin&7)<<2));} \
}
#define PIN_INPUT(port, pin) { \
if (pin < 8) { GP_INP(port, CRL, 0xF<<((pin)<<2)); } \
else { GP_INP(port, CRH, 0xF<<((pin&7)<<2)); } \
}
#define PIN_HIGH(port, pin) (port)-> REGS(BSRR) = (1<<(pin))
#define PIN_LOW(port, pin) (port)-> REGS(BSRR) = (1<<((pin)+16))
#define RD_PORT GPIOB
#define RD_PIN 1
#define WR_PORT GPIOB
#define WR_PIN 0
#define CD_PORT GPIOA
#define CD_PIN 7
#define CS_PORT GPIOA
#define CS_PIN 6
#define RESET_PORT GPIOA
#define RESET_PIN 5
// configure macros for the data pins
#define AMASK 0x060F
#define BMASK 0x00C0
#define write_8(d) { GPIOA->REGS(BSRR) = AMASK << 16; GPIOB->REGS(BSRR) = BMASK << 16; \
GPIOA->REGS(BSRR) = (((d) & 3) << 9) | (((d) & 0xF0) >> 4); \
GPIOB->REGS(BSRR) = (((d) & 0x0C) << 4); \
}
#define read_8() (((GPIOA->REGS(IDR) & (3<<9)) >> 9) | ((GPIOA->REGS(IDR) & (0x0F)) << 4) | ((GPIOB->REGS(IDR) & (3<<6)) >> 4))
// PA10,PA9 PA3-PA0 PB7,PB6
#define setWriteDir() {GP_OUT(GPIOA, CRH, 0xFF0); GP_OUT(GPIOA, CRL, 0xFFFF); GP_OUT(GPIOB, CRL, 0xFF000000); }
#define setReadDir() {GP_INP(GPIOA, CRH, 0xFF0); GP_INP(GPIOA, CRL, 0xFFFF); GP_INP(GPIOB, CRL, 0xFF000000); }
#define write8(x) { write_8(x); WRITE_DELAY; WR_STROBE; }
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst) { RD_STROBE; READ_DELAY; dst = read_8(); RD_IDLE; }
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
when TFT Data is on PA0-7 this could not be right
#define CD_PORT GPIOA
#define CD_PIN 7
#define CS_PORT GPIOA
#define CS_PIN 6
#define RESET_PORT GPIOA
#define RESET_PIN 5
#define RD_PORT GPIOB
//#define RD_PIN 5
#define RD_PIN 0 //hardware mod to Adapter. Allows use of PB5 for SD Card
Yes, that means LCD_RD is PB0. LCD_RST is PB9 etc
Follow the preferred wiring. Test with the readreg sketch. And the library should "work out of the box".
Just like if you had plugged your Shield into a regular Nucleo board.
The SPFD5408 is one of the slowest controllers. But it should be ok with the STM32F103. Cortex-M4 STM32 are a lot faster.
Verify with readreg sketch first.
David.
Edit. You are quoting the MY_BLUEPILL special from the mcufriend_special.h
I was quoting the BLUEPILL shield from the mcufriend_shield.h.
Alright
but the PIN LCD_RS is not defined
How could i use the standard wiring on the readreg.ino ? if i delete the #define part i got a error
i use a STM32F103C8t6 board i dont have a nucleo
i connected now as in the libary described
i think CD is equal too RD?
but i use the diagnose_TFT_support
on serial monitor i got this
Diagnose whether this controller is supported
There are FAQs in extras/mcufriend_how_to.txt
tft.readID() finds: ID = 0xD3D3
MCUFRIEND_kbv version: 2.9.9
Probably a write-only Mega2560 Shield
Try to force ID = 0x9481
PORTRAIT is 320 x 480
Run the examples/graphictest_kbv sketch
All colours, text, directions, rotations, scrolls
should work. If there is a problem, make notes on paper
Post accurate description of problem to Forum
Or post a link to a video (or photos)
I rely on good information from remote users
The data/control pin is often known by different names e.g. RS, DC, ...
Register Select, Data Control, Command Data, ... are all used.
If you want to pursue Electronics as a hobby, you must learn to use Google especially Wikipedia.
The idea behind this library is to "plug in a shield and go"
You can buy a Nucleo board from any STMicroelectronics Distributor. They are excellent value. Ideal for experiments or prototyping.
If you are not happy with hand-wiring a BluePill, you can always buy an Arduino Zero or Due.
David.
Edit. Einstein would have a pretty good guess what LCD_RD, LCD_WR, LCD_CS, LCD_RST mean.
If he nipped out of his grave, he could have asked Google about LCD_RS.
Electronics is my hobby since over 6 Years and for sure i know only a little bit about electronics.
i try the last days diffrent solutions from google but it doesn´t work. Thats why i asked here in the forum.I saw in previous posts that you are "Einstein" in category display solutions. So i was very happy that you comment my post.
i double check the wiring and it works now
Thank you for your help.
Do you have a tip if i want to use the touch.
Run the Calibration_native example on your Uno.
This will identify the Touch pins e.g. XM, YP etc
For example. If XM is A1 on the Uno, this corresponds to LCD_WR on the Shield. PB6 on your Bluepill.
I suspect that you are using Roger's weird MapleCore which needs pins to be declared as PB0, PB6 etc.
Nucleos have proper Arduino headers. So they have proper Arduino pin numbers.
A Nucleo will use regular numbers like on a proper Arduino. A program that works on Uno will work out of the box on a 180MHz Nucleo.
The ST Core will work with the Adafruit TouchScreen.h (with a small edit)
The weird Maple Core will not work with TouchScreen.h but there might be a special TouchScreen_STM.h that is for Maple.
David.
Alight Touch is also working now.
But only when set the Rotation to 2 when i set the Rotation to 0 it isn´t possible too change the pinout right.
X or Y is always inverted. Have i to change something in the libary ?
I use the TouchScreen_STM32.
My calibration program will diagnose XM, YP, YM, XP pins
It will also give you values for TS_LEFT, TS_RT, ... etc as 10-bit ADC values
The TouchScreen_STM.h library will give you 12-bit values.
I presume that you just need to multiply TS_LEFT by 4 to get a 12-bit value.
You use map() to calculate the pixel coordinates.
Surely you would have learned all of this from using the Shield on the proper Uno.
David.
i try it with your program but i got the message
TouchScreen.h GFX Calibration
Not possible to diagnose Touch pins on ARM or ESP32
ID = 0x5408