STM32F103VET6 with 4" TFT parallel 16 bits display

I am trying to use one 4" TFT parallel 16 bits display wired to a generic board STM32F103VET6 but I could not find a right configuration for both libraries I have tried: MCUFRIEND_kbv and GxTFT. I have almost all IO pins available for that connection i.e. PA0~PA15, PB0~PB15, PC0~PC15, PD0~PD15, PE0~PE15... I will appreciate if someone could give me some advice about how to correctly configure the library to work with that combination of board/display. Thanks 1k !

Display: 4.0inch 8&16BIT Module ST7796S SKU:MRB3951 - LCD wiki

Board..: https://www.aliexpress.com/item/33047262765.html

...

Surely LCDWIKI have example code.

You can use MCUFRIEND_kbv if you tell me which pins you want to use. (And test with LCD_ID_readreg.ino first)

Note that some port pins are used for Serial, SWD, ...
Life is simpler with 8080-8 interface. But 8080-16 is fine if you have enough pins.

David.

david_prentice:
Surely LCDWIKI have example code.

You can use MCUFRIEND_kbv if you tell me which pins you want to use. (And test with LCD_ID_readreg.ino first)

Note that some port pins are used for Serial, SWD, ...
Life is simpler with 8080-8 interface. But 8080-16 is fine if you have enough pins.

David.

Thank you David. Since my project is at begining and besides TFT display I will use only two analog and two digital pins I have almost all pins available, except that can not be used such USB+/USB-/RX/TX/ etc. I am think about use PE0 to PE15 for data bits and controls CS, RS, RD, WR, RST, etc anywere else. I would like to receive some suggestion and also, the most important for me, how to configure the MCUFRIEND_kbv to use that choosen pins correctly. Would you so please help ? Thanks again

Hi Antonio, Hi David,

Yet another interesting 4" TFT display we will certainly hear more of in this forum.

Most likely easier to use than the ones with OTM8009A. :slight_smile:

A quick search on AliExpress provided links to shops I already know:

Surenoo 4.0" inch 480*320 8/16-Bit Parallel MCU ST7796S TFT LCD Module Display Screen w/ XPT2046 Resistive Touch Panel & PCB Adpater

Ecyberspaces maithoga 4.0 inch HD TFT LCD Touch Screen with PCB Board ILI9488 ST7796S Drive IC 320(RGB)*480 8Bit Parallel Interface

Most likely Maithoga is the original manufacturer of the panel.

And a shop I don't know, but with more information:

4.0inch TFT LCD Parallel-Port LCD Resolution 320*480 4.0inch LCD Display Module 4.0in LCD Board Driver IC ST7796S

I don't have any display with ST7796S yet, therefore GxTFT has no support for it.

I do have the same STM32 board, but had no time to use it yet.
I would first take a look which pins are the FSMC data pins; they might be in useful arrangement.
No, this isn't the case.

Jean-Marc

AntonioTesta:
Thank you David. Since my project is at begining and besides TFT display I will use only two analog and two digital pins I have almost all pins available, except that can not be used such USB+/USB-/RX/TX/ etc. I am think about use PE0 to PE15 for data bits and controls CS, RS, RD, WR, RST, etc anywere else. I would like to receive some suggestion and also, the most important for me, how to configure the MCUFRIEND_kbv to use that choosen pins correctly. Would you so please help ? Thanks again

You tell me your wiring. I will write the SPECIAL for you.

If it is a ready-made board with a 34-pin socket to receive the TFT, just post a link to the board.
If you intend to use trailing wires, I ask that you test your wires first with LCD_ID_readreg.ino

David.

p.s. I would take some Protoboard. Solder a 34-pin socket for TFT. Solder sockets for dev board. Solder appropriate connecting wires between each socket.

David, on page 9 of its TFT user manual at http://www.lcdwiki.com/res/MRB3951/4.0inch_8&16BIT_Module_MRB3951_User_Manual_EN.pdf there is a suggestion for connections of this TFT to STM32F103RCT6. This STM32 is not exactly my microprocessor but I think it is similar to STM32F103VET6.

The connection they suggest is attached.

Do you think I will have success if I connect the TFT to STM32F103VET6 as shown in attached scheme ? If yes, how to find the right MCUFRIEND_kbv configuration for it ?

The problem with this scheme is that the most interesting signal are located at PB port pins and all PB pins will be used for data transfer to/from TFT !!! In my case, the better option for TFT data transfer would be the 16 bits of PE port... So, imagine the attached scheme changing the PB0~PB15 by PE0~PE15.

Thanks so much

ZinggJM:
Hi Antonio, Hi David,

Yet another interesting 4" TFT display we will certainly hear more of in this forum.

Most likely easier to use than the ones with OTM8009A. :slight_smile:

...
...

Holla Jean-Marc, I gave up of OTM8009A since the problems you know already. This one 4.0inch 8&16BIT Module ST7796S SKU:MRB3951 - LCD wiki was choosen since it has Back Light control signal, Touch IRQ signal and the most important for me: its memory is Read/Write. The challenge now is put it to work with a minimal STM32F103VET6 board https://www.aliexpress.com/item/33047262765.html...

Connect your TFT according to the LCDWIKI scheme.
Run the LCDWIKI examples
e.g. 4.0inch_8&16BIT_Module_ST7796S_MRB3951_V1.0\1-Demo\Demo_STM32\Demo_Elite_STM32F103ZET6_8&16_BIT_FSMC\USER\main.c

Your VET6 chip is almost the same as the ZET6. It should have the FSMC interface

When this works correctly I will post the equivalent SPECIAL for Arduino.

If both LCDWIKI and MCUFRIEND_kbv work 100% with this wiring, I will post the PORTE version.

I assume that you are using the Arduino Core from STMicroelectronics.

I believe that Jean-Marc has an STM32 board with a 34-pin female TFT header.
Most dev boards seem to have male headers that obviously will not mate with your display male.

David.

Edit. The STM32 dev boards have a 32-pin TFT male header. And matching 32-pin display with female socket.
Of course, 32-pin, 34-pin, 40-pin displays all have different pinouts. You have to check very carefully before purchase.

Ok David, I will do that and tell you the results. Thanks

david_prentice:
Connect your TFT according to the LCDWIKI scheme.
Run the LCDWIKI examples
e.g. 4.0inch_8&16BIT_Module_ST7796S_MRB3951_V1.0\1-Demo\Demo_STM32\Demo_Elite_STM32F103ZET6_8&16_BIT_FSMC\USER\main.c

Your VET6 chip is almost the same as the ZET6. It should have the FSMC interface

When this works correctly I will post the equivalent SPECIAL for Arduino.

If both LCDWIKI and MCUFRIEND_kbv work 100% with this wiring, I will post the PORTE version.

I assume that you are using the Arduino Core from STMicroelectronics.

I believe that Jean-Marc has an STM32 board with a 34-pin female TFT header.
Most dev boards seem to have male headers that obviously will not mate with your display male.

David.

Edit. The STM32 dev boards have a 32-pin TFT male header. And matching 32-pin display with female socket.
Of course, 32-pin, 34-pin, 40-pin displays all have different pinouts. You have to check very carefully before purchase.

Hello David, bellow few updates about the case:

  1. The connection scheme for STM32F103ZET6 (page 10 of wiki.lcd manual http://www.lcdwiki.com/res/MRB3951/4.0inch_8&16BIT_Module_MRB3951_User_Manual_EN.pdf) use few pins from port G. The module I am using https://www.aliexpress.com/item/33047262765.html is based on 100 pins version of the STM32F103. In this version there are ports PA, PB, PC, PD and PE available. Port PG is available in the 144 pins version only. So it seams that scheme on page 9, for STM32F103RCT6, is the most similar to my module. Do you think there is a chance to get success using theSTM32F103RCT6 scheme and test it with the lcd wiki exemple Demo_Mini_STM32F103RCT6_8&16_BIT_IO_Simulation ?

  2. Unfortunatelly the module I will use does not have the 32 or 34 pin TFT header. I am aware about manual connections that should be done. Anyway thanks for highlight that issue...

Ah-ha. Boards do exist that receive 34-pin displays e.g. punctual atom mini

And punctual atom Apollo F767

Page #9 of the User Manual has wiring for the punctual atom mini.

So build that example.

Unfortunatelly the module I will use does not have the 32 or 34 pin TFT header.

I am horrified. So you have just got a bare panel with dangling ribbon !!
And you expect to connect the ribbon with random trailing wires ?

I admire your courage. Build and run the LCDWIKI Mini project.

My ST7796 8-bit Shield arrived today. It works 100%. I have added a separate init sequence. Previously it shared the ILI9488 init sequence.

David.

david_prentice:
...
...
I am horrified. So you have just got a bare panel with dangling ribbon !!
And you expect to connect the ribbon with random trailing wires ?
I admire your courage. Build and run the LCDWIKI Mini project.
...
...
David.

Actually I am drawing a PCB specially to receive the STM32F103VET6 module, the 4" TFT and few aditional components. So the wiring from STM32 to the TFT header pins will be done by Eagle software. I am not so corageous as you mentioned !!! Back to MACUFRIEND_kbv library I would suggest one mcufriend_special.h for many differents STM32F103. Since the small versions of STM32F103 use ports PA, PB and PC for shared signals, probably the best option for connection scheme would be PD0~PD15 (for data 8 or 16 bits), PB15, PB14, PB13, PB12 for RD, WR, CS, RS, and PB6, PB7 for RESET, BACKLIGHT. This scheme is up to work with a wide variety of STM32F103 such VB, VC, VF, ZC, ZE, ZF... and many others. Every STM32F103 versions 100 or 144 pins would work under that scheme. Do not you think this mcufriend_special.h would be usefull for many STM32 users ?

@David, I was surprised that you didn't ask for a (clickable) link to the TFT in question.

@Antonio, writing a "special" that uses a single port with 8 or 16 pins in order is trivial, you could do it yourself.

Jean-Marc

I did not ask for a clickable link because I assumed that Antonio is familiar with STM32, Keil, soldering, ...

I would definitely prototype with a 34-pin module rather than a bare panel.
Before I would not even dream of designing a custom pcb as a first step.

The real mystery is the elderly Cortex-M3 F103. ST makes M4 and M7 chips with infinitely better performance. Their peripherals work consistently. The F103 has an unusual GPIO setup.

Writing a SPECIAL for random wiring is straightforward but fiddly. Trivial for PORTs with adjacent bits.

David.

david_prentice:
Ah-ha. Boards do exist that receive 34-pin displays e.g. punctual atom mini

And punctual atom Apollo F767

Page #9 of the User Manual has wiring for the punctual atom mini.

So build that example.
I am horrified. So you have just got a bare panel with dangling ribbon !!
And you expect to connect the ribbon with random trailing wires ?

I admire your courage. Build and run the LCDWIKI Mini project.

My ST7796 8-bit Shield arrived today. It works 100%. I have added a separate init sequence. Previously it shared the ILI9488 init sequence.

David.

Hello David,

Finally I concluded tests with display wired to STM32F103VET6 according to page#9 of Lcdwiki manual. It works ! Now the challenge is wire them according to the following: Display D0~D15 to PD0~PD15, CS to PB15, RS to PB14, RD to PB13, WR to PB12, RST to PB8 or to MCU reset. This connections are perfect to module STM32F103VET6. Maybe you could give me some advices about how to create a special for that. If it is easy please tell me the most similar that already exists so that I can make the appropriate changes or, if you want, you would add this special to your library. Thanks so much for all...

I need to see what defines are in your command line. i.e. what Core

#elif defined(USE_ANTONIOTESTA) && (defined(ARDUINO_GENERIC_STM32F103V) || defined(ARDUINO_GENERIC_F103VE)) // MAPLECORE or STM32CORE 
#warning Using USE_ANTONIOTESTA
#define USES_16BIT_BUS
#if defined(ARDUINO_ARCH_STM32)   //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&7)<<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  13
#define WR_PORT GPIOB
#define WR_PIN  12
#define CD_PORT GPIOB
#define CD_PIN  14
#define CS_PORT GPIOB
#define CS_PIN  15
#define RESET_PORT GPIOB
#define RESET_PIN  8

// configure macros for the data pins on PD0-PD15
#define DMASK 0xFFFF
#define write_16(d) { \
        GPIOD->REGS(BSRR) = (DMASK) << 16; \
        GPIOD->REGS(BSRR) =  d; \
   }

#define read_16()     ( (GPIOD->REGS(IDR) & DMASK) )

//                                        PD15-PD8                        PD7-PD0
#define setWriteDir() {GP_OUT(GPIOD, CRH, 0xFFFFFFFF); GP_OUT(GPIOD, CRL, 0xFFFFFFFF); }
#define setReadDir()  {GP_INP(GPIOD, CRH, 0xFFFFFFFF); GP_INP(GPIOD, CRL, 0xFFFFFFFF); }

#define write8(x)     { write16((x) & 0xFF); }
#define write16(x)    { write_16(x); WRITE_DELAY; WR_STROBE; WR_IDLE; WR_IDLE; }
#define READ_16(dst)  { RD_STROBE; READ_DELAY; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
#define READ_8(dst)   { READ_16(dst); dst &= 0xFF; }

If successful you should see this message in orange:

warning Using USE_ANTONIOTESTA

Edit. Corrected the #elif condition. i.e. defined(ARDUINO_GENERIC_STM32F103V) should get MAPLECORE now.
Add a #define USE_ANTONIOTESTA to the top of mcufriend_special.h and add your new #elif block to the existing #elif blocks

Edit. Corrected the extraneous ( in read_16() macro
Edit. Corrected ARDUINO_GENERIC_STM32F103VE for STM32CORE v1.9.0
Edit. Corrected ARDUINO_GENERIC_F103VE for STM32CORE v1.9.0
Edit. Corrected write_16(d) macro

Thanks David. Please tell me in which mcufrind library module and where exactly I need to insert the code you've wrote... Anyway I think we are almost there !!! tks

Follow the instructions in the mcufriend_how_to.txt file on SPECIALs.

But most importantly. I need to know which Core and board you are using in the Arduino IDE.
I have selected the official STM32->Generic STM323F1->Generic STM32F103RET6 (Blue Button)

Builds use these defines:

-DSTM32F1xx -DARDUINO=10812 -DARDUINO_GENERIC_F103RET6 -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"GENERIC_F103RET6\"" -DSTM32F103xE -DHAL_UART_MODULE_ENABLED

I have to determine the correct conditional block.

If you use the weird MapleCore it might be:

-DF_CPU=72000000L -DARDUINO=10812 -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103VE -D__STM32F1__

David.

Ooops... I forgot to mention. I am using the "Generic STM32F103V series" with STM32F103VET6 microprocessor...

I have edited #15.

Obviously untested. Please can you let me know how you get on.

David.