Git Product home page Git Product logo

arduino-stm32-8bittft's Introduction

Arduino-STM32-8bitTFT

8bit TFT Library for Arduino_Core_STM32(ST Core)

I ported from here.
https://github.com/prenticedavid/MCUFRIEND_kbv


Software requirement


Wirering for 8bit Parallel TFT

TFT STM32
LCD_RD -- PB0(*1)
LCD_WR -- PB1(*1)
LCD_RS -- PB5(*1)
LCD_CS -- PB6(*1)
LCD_RST -- PB7(*1)
LCD_D0 -- PA0(*2)
LCD_D1 -- PA1(*2)
LCD_D2 -- PA2(*2)
LCD_D3 -- PA3(*2)
LCD_D4 -- PA4(*2)
LCD_D5 -- PA5(*2)
LCD_D6 -- PA6(*2)
LCD_D7 -- PA7(*2)
5V -- 5V(*3)
3.3V -- 3.3V(*3)
GND -- GND

(*1)
You can change to other PB pin. To change the pin, change Arduino-STM32-8bitTFT.h.
Some boards assign PB3 and PB4 to the JTAG debug port by default.
Therefore, depending on the board, PB3 and PB4 may not be available as GPIO.
These GPIO are controlled using LL_GPIO_WriteOutputPort().

#define TFT_RD         LL_GPIO_PIN_0 // PB0
#define TFT_WR         LL_GPIO_PIN_1 // PB1
#define TFT_RS         LL_GPIO_PIN_5 // PB5
#define TFT_CS         LL_GPIO_PIN_6 // PB6
#define TFT_RST        LL_GPIO_PIN_7 // PB7

(*2)
Serial.print of NUCLEO and DISC1 gose to PA2.
Serial.print of STM32G series gose to PA2.
Serial.print of STM32H series gose to PA0.
If you are using these, you will need to do one of the following:

Change GPIO from D0 to D7

To change the port, change Arduino-STM32-8bitTFT.h.
D0 to D7 are controlled using CMSIS ODR Register.
This register can change multiple IOs at once, but only IOs on the same port.
Therefore, D0 to D7 must be the same port.
If PORT-A is used for D0-D7, all GPIOs on PORT-A cannot be used for other purposes.
Because CMSIS ODR Register manipulates all GPIOs of PORT-A.

You can use any of the following:

  • PORT-A LOW
    TFT Pin|D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
    STM32 Pin|PA7|PA6|PA5|PA4|PA3|PA2|PA1|PA0|
  • PORT-A HIGH
    TFT Pin|D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
    STM32 Pin|PA15|PA14|PA13|PA12|PA11|PA10|PA9|PA8|
  • PORT-C LOW
    TFT Pin|D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
    STM32 Pin|PC7|PC6|PC5|PC4|PC3|PC2|PC1|PC0|
  • PORT-C HIGH
    TFT Pin|D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
    STM32 Pin|PC15|PC14|PC13|PC12|PC11|PC10|PC9|PC8|
  • PORT-D LOW
    TFT Pin|D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
    STM32 Pin|PD7|PD6|PD5|PD4|PD3|PD2|PD1|PD0|
  • PORT-D HIGH
    TFT Pin|D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
    STM32 Pin|PD15|PD14|PD13|PD12|PD11|PD10|PD9|PD8|

Change default Serial instance pins

You can use another GPIO as a Serial object.
GPIO that can be used as a Serial object differs depending on the MCU.
You can know which GPIOs can be used in PeripheralPins.c of the MCU.
PeripheralPins.c is here.

  Serial.setTx(PB3);
  Serial.setRx(PB4);
  Serial.begin(115200);

(*3)
When a regulator(It's often AMS1117) is mounted on the back, it's operated 5V.
When a regulator is NOT mounted on the back, it's operated 3.3V.

Note:Keep the wire length as short as possible.


Tested TFT

  • ILI9325 2.4inch 240x320 TFT-Shield
  • ILI9341 2.4inch 240x320 TFT-Shield
  • ILI9342 2.4inch 240x320 TFT-Shield
  • SPFD5408 2.4inch 240x320 TFT-Shield
  • R61505 2.4inch 240x320 TFT-Shield
  • ST7783 2.4inch 240x320 TFT-Shield
  • LGDP4532 2.4inch 240x320 TFT-Shield
  • R61509V 3.6inch 240x400 TFT-Shield
  • ST7793 3.6inch 240x400 TFT-Shield
  • ILI9481 3.5inch 320x480 TFT-Shield
  • ILI9486 3.5inch 320x480 TFT-Shield
  • RM68140 3.95inch 320x480 TFT-Shield
  • ST7796 3.95inch 320x480 TFT-Shield

I found that these display cannot follow high-speed GPIO-ON and GPIO-OFF.

  • OPEN-SMART ILI9225 TFT-Shield
  • OPEN-SMART ILI9327 TFT-Shield
  • OPEN-SMART ILI9340 TFT-Shield
  • OPEN-SMART S6D1121 16Pin-Parallel
  • OPEN-SMART ST7775 16Pin-Parallel
  • OPEN-SMART ST7783 16Pin-Parallel
  • OPEN-SMART R61509V 16Pin-Parallel
  • OPEN-SMART ILI9488 16Pin-Parallel

TFT-SHIELD-2


Boards available

This library uses LL GPIO Generic Driver and CMSIS ODR Register.
Probably all boards have these available.
I tested with these.

  • STM32F0/F1/F3/F4 series
  • STM32G4 series
  • STM32H5 series
  • STM32L4 series

Setting your TFT's resolution

The default resolution of this library is 240x320.
If your TFT's resolution is 320x480,
you have to set your TFT's resolution using tft.setResoution.

ID = tft.readID();
tft.setResolution(320, 480); // Set your resolution
Serial.print("Device ID: 0x"); Serial.println(ID, HEX);
tft.begin(ID);
uint32_t width = tft.width();
Serial.print("Width: "); Serial.println(width); // You will see 320
uint32_t height = tft.height();
Serial.print("Height: "); Serial.println(height); // You will see 480

If your TFT's resolution is 240x400,
you have to set your TFT's resolution and TFT's offset.

ID = tft.readID();
tft.setResolution(240, 400); // Set your resolution
tft.setOffset(32); // Set your offset
Serial.print("Device ID: 0x"); Serial.println(ID, HEX);
tft.begin(ID);
uint32_t width = tft.width();
Serial.print("Width: "); Serial.println(width); // You will see 240
uint32_t height = tft.height();
Serial.print("Height: "); Serial.println(height); // You will see 400

  • STM32F103 + R61505 2.4 inch TFT

r61505

  • STM32F103 + SPFD5408 2.4 inch TFT

spfd5408

  • STM32F103 + ILI9325 2.4 inch TFT

ili9325

  • STM32F103 + ILI9341 2.4 inch TFT

ili9341

  • STM32F103 + ILI9342 2.4 inch TFT

ili9342

  • STM32F401 + ILI9341 2.4 inch TFT

STM32F401

  • STM32F407 + ILI9341 2.4 inch TFT

STM32F407

  • NUCLEO F446RE + ILI9341 2.4 inch TFT (Use PC0-PC7 for D0-D7)

8bitTFT

  • STM32G431 + ILI9341 2.4 inch TFT (Use Serial remapping)

STM32G431

  • STM32H750 + ILI9341 2.4 inch TFT (Use PC0-PC7 for D0-D7)

STM32H750


Benchmark using ILI9341(240x320)

Benchmark F072 F103 F303 F401 F411 F407 F446 G431 H750 L452 ATmega328
Screen fill 713964 737158 358057 247223 216304 141878 132427 140239 222478 259637 1379560
Text 73319 58985 37647 25814 22605 15097 14272 16275 14691 28825 344024
Lines 675985 556282 336332 235522 206064 137693 130958 134605 147000 250545 3390180
Horiz/Vert Lines 60070 61299 30165 20825 18221 11958 11173 11847 18372 21950 144664
Rectangles (outline) 39824 39994 20040 13835 12106 7953 7437 8178 11863 14875 104260
Rectangles (filled) 1482576 1530389 743518 513383 449170 294609 274991 291313 461782 539271 3267476
Circles (filled) 237519 215466 120380 83212 72840 48080 45358 58606 59632 97797 1211484
Circles (outline) 297537 245302 148705 103680 90733 60769 57622 59807 64510 110695 1475108
Triangles (outline) 149009 123427 74211 51938 45477 30354 28766 29767 32825 55313 1075596
Triangles (filled) 542331 528554 268777 185711 162496 106788 99944 112922 155465 202875 1721636
Rounded rects (outline) 117285 101407 58746 40758 35682 23791 22529 23750 27519 43702 506428
Rounded rects (filled) 1495318 1534484 750346 518107 453320 297450 277742 298242 132427 548296 3795228

arduino-stm32-8bittft's People

Contributors

nopnop2002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

arduino-stm32-8bittft's Issues

16-bit mode with FSMC

Hey!
I am using STM32F407VET6 board: https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0
This board has a 16-bit FSMC interface.
This interface makes it easier to work with the TFT display and significantly speed up drawing on the display.
I found the only library that works with this interface: https://github.com/stevstrong/Adafruit_TFTLCD_16bit_STM32
The library is running and the display shows an image.
But this library only works with Arduino_STM32 core: https://github.com/rogerclarkmelbourne/Arduino_STM32
But this is not a complete core. Support for F407 series microcontrollers is very limited. Many functions do not work correctly or do not work at all.
Arduino_Core_STM32 core is very good: https://github.com/stm32duino/Arduino_Core_STM32
But I did not find support for TFT displays with FSMC in it.
Can you modify the library to support 16-bit displays with FSMC interface?

16 pin ILI9488 3.5inch 320x480 with STM32F411CE won't work for me.

I've got an Open-Smart 16 pin ILI9488 3.5inch 320x480 "expansion module" from e-bay.
https://www.ebay.com/itm/3-5inch-TFT-Board-Expansion-Module-LCD-Touch-Screen-For-R3-Nano-Mega2560-Hot/233641518844?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649
I hooked it up to a Black Pill STM32F411CE.
I looked at the .cpp and saw it briefly mentioned the ILI9488 but I'm not sure if it supports it. (I don't really understand the code.) I'm probably doing something wrong.
I ran the GraphicsTest_320x480_SMT32.ino and it looks like it is communicating with each other but there is nothing on the tft screen. In the Serial Monitor I am seeing this;

Arduino-STM32-8bitTFT
readReg16(0)=0x0
readReg32(A1)=0x3093
readReg40(BF)=0x9393
readReg32(D4)=0x0
readReg40(EF)=0x0
readReg32(FE)=0x0
readReg32(04)=0x548066
readReg32(D3)=0x9488
Device ID: 0x9488
Width: 320
Height: 480
Benchmark Time (microseconds)
Screen fill 2115372
Text 77333
Lines 962493
Horiz/Vert Lines 182033
Rectangles (outline) 108761
Rectangles (filled) 5310698
Circles (filled) 1258549
Circles (outline) 411223
Triangles (outline) 194504
Triangles (filled) 1925425
Rounded rects (outline) 197330
Rounded rects (filled) 5885654
Done!

20210127_100740
20210127_100749
20210127_100914
20210127_101018

Thank you in advance for any help you could give me.
Doug

Doesn't work on stm32f401ccu6

Code in example doesn't work on stm32f401ccu6 v3.0 + display ILI9486 with core from ST

After the code LCD_ID_Reader.ino is executed, i.e. the pins are connected correctly, the ID is readable.

reg(0x00D3) 00 00 94 86.ILI9341, ILI9488

I connected black pill to display as below:

TFT   STM32
LCD_RD -- PB0(*1)
LCD_WR -- PB1(*1)
LCD_RS -- PB5(*1)
LCD_CS -- PB6(*1)
LCD_RST -- PB7(*1)
LCD_D0 -- PA0(*2)
LCD_D1 -- PA1(*2)
LCD_D2 -- PA2(*2)
LCD_D3 -- PA3(*2)
LCD_D4 -- PA4(*2)
LCD_D5 -- PA5(*2)
LCD_D6 -- PA6(*2)
LCD_D7 -- PA7(*2)
And change code in Arduino-STM32-8bitTFT.h
#define TFT_RD         LL_GPIO_PIN_0 // Px0
#define TFT_WR         LL_GPIO_PIN_1 // Px1
#define TFT_RS         LL_GPIO_PIN_5 // Px5
#define TFT_CS         LL_GPIO_PIN_6 // Px6
#define TFT_RST        LL_GPIO_PIN_7 // Px7

White screen.
white_stm_8_bit
I connected black pill to display as below:

TFT   STM32
LCD_RD -- PB3(*1)
LCD_WR -- PB4(*1)
LCD_RS -- PB5(*1)
LCD_CS -- PB6(*1)
LCD_RST -- PB7(*1)
LCD_D0 -- PA0(*2)
LCD_D1 -- PA1(*2)
LCD_D2 -- PA2(*2)
LCD_D3 -- PA3(*2)
LCD_D4 -- PA4(*2)
LCD_D5 -- PA5(*2)
LCD_D6 -- PA6(*2)
LCD_D7 -- PA7(*2)
And change code in `Arduino-STM32-8bitTFT.h`
#define TFT_RD         LL_GPIO_PIN_3 // Px3
#define TFT_WR         LL_GPIO_PIN_4 // Px4
#define TFT_RS         LL_GPIO_PIN_5 // Px5
#define TFT_CS         LL_GPIO_PIN_6 // Px6
#define TFT_RST        LL_GPIO_PIN_7 // Px7

Screen white also...
Same hardware work good with TFT_eSPI and pins as below:

// common "MCUfriend" shields
#define TFT_CS   PB8  // Chip select control pin
#define TFT_DC   PB7  // Data Command control pin
#define TFT_RST  PB9  // Reset pin

#define TFT_WR   PB6  // Write strobe control pin 
#define TFT_RD   PB0  // Read pin

#define TFT_D0   PA0  // 8 bit parallel bus to TFT
#define TFT_D1   PA1
#define TFT_D2   PA2
#define TFT_D3   PA3
#define TFT_D4   PA4
#define TFT_D5   PA5
#define TFT_D6   PA6
#define TFT_D7   PA7

work_eTFT_sPI
I changed in the library TFT_eSPI pins as for the library and everything worked.

#define TFT_RD   PB0  // Read pin
#define TFT_WR   PB1  // Write strobe control pin 
#define TFT_DC   PB5  // RS/CD - Data Command control pin
#define TFT_CS   PB6  // Chip select control pin
#define TFT_RST  PB7  // Reset pin

#define TFT_D0   PA0  // 8 bit parallel bus to TFT
#define TFT_D1   PA1
#define TFT_D2   PA2
#define TFT_D3   PA3
#define TFT_D4   PA4
#define TFT_D5   PA5
#define TFT_D6   PA6
#define TFT_D7   PA7

pins_as_stm32_8bit

When I changed the pins in various options for the library Arduino-STM32-8bitTFT nothing worked and the screen was still white.
You write that the library works with ILI9486, but I did not find initialization in the code, for ILI9481 only:
case 0x9481: //ILI9481

Open-Smart ILI9225 8bit Support

I have an ILI9225 Parallel TFT 2.0" display with the following wiring, but i only see white screen with STM32F401 MCU.

D0-D7 -> PA0->PA7, TFT_CS -> PB8, TFT_DC -> PB5, TFT_RST -> PB9, TFT_WR -> PB1, TFT_RD -> PB0

I use this config:

#define TFT_DATA GPIOA
#define TFT_PORT PORT_LOW
#define TFT_D0 LL_GPIO_PIN_0
#define TFT_D1 LL_GPIO_PIN_1
#define TFT_D2 LL_GPIO_PIN_2
#define TFT_D3 LL_GPIO_PIN_3
#define TFT_D4 LL_GPIO_PIN_4
#define TFT_D5 LL_GPIO_PIN_5
#define TFT_D6 LL_GPIO_PIN_6
#define TFT_D7 LL_GPIO_PIN_7

#define TFT_RD LL_GPIO_PIN_0
#define TFT_WR LL_GPIO_PIN_1
#define TFT_RS LL_GPIO_PIN_5
#define TFT_CS LL_GPIO_PIN_8
#define TFT_RST LL_GPIO_PIN_9

An ILI9341 display works fine with the same setup.
Is the ILI9225 display not supported?

(The ILI9225 display also works with the TFT_eSPI library)

readReg40(BF)=0x0
readReg32(D4)=0x0
readReg40(EF)=0x1818
readReg32(FE)=0x0
readReg32(04)=0x0
readReg32(D3)=0x0
readReg16(0)=0x9226
Device ID: 0x9226
Width: 176
Height: 220

direct write registor will be more faster

connet lcd data pin to a GPIO pot 0~7pin,then change the function STM32_TFT_8bit::write8 to:

void STM32_TFT_8bit::write8(uint8_t bytes) {
    TFT_DATA->ODR = bytes;
}

write speed will more fast, here is my benchmark result, left is after change, my board is F411CEU6

2023_06_21_21_39_05

2023_06_21_21_42_13

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.