「BluePill」や「BlackPill」の使用が「ST-LINK」導入によりとても楽になりました。
対象マイコン | ボードの通称 | Arduino IDE 内でのBoard,Board Part Number |
---|---|---|
STM32F103C8T6 | BluePill | Generic STM32F1 series,BluePill F103CB(or C8 with 128k) |
STM32F411CEU6 | BlackPill | Generic STM32F4 series,BlackPill F411CE |
両方に8ビットパラレル接続TFTモジュール(ILI9488)を繋ぎ、"Arduino IDE 2.3.2"の
File -> Examples -> TFT_eSPI -> 480x320 -> UTFU_Demo_480x320.ino
を動作させ比較してみました。それぞれのピン接続は全く同じには出来ず、次のようにしました。
8Bit Parallel TFT | BluePill | BlackPill |
---|---|---|
LCD_RST | PB3 | PA0 |
LCD_CS | PB4 | PA1 |
LCD_RS(DC) | PB5 | PA2 |
LCD_WR | PB6 | PA3 |
LCD_RD | PB7 | PA4 |
LCD_D0 | PA0 | PB0 |
LCD_D1 | PA1 | PB1 |
... | ||
LCD_D7 | PA7 | PB7 |
写真の右下の部分は見ずらいですが
BluePill(72MHz)=1418 msecs BlackPill(100MHz)=993 msecs
となっており、ほぼ動作周波数の比率になっています。なお、どちらも
Tools -> Optimize: Fastest(-O3) with LTO
でコンパイルしており、5%程度高速化されていると思います。
以下に、TFT_eSPIライブラリでのBLuePillのUser_Setup.hを示します。
User_Setup.h
// USER DEFINED SETTINGS
#define USER_SETUP_INFO "User_Setup"
// Define STM32 to invoke optimised processor support (only for STM32)
#define STM32
#define STM_PORTA_DATA_BUS
#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
// Tell the library to use 8 bit parallel mode (otherwise SPI is assumed)
#define TFT_PARALLEL_8_BIT
#define TFT_CNTRL_PORT GPIOB
#define TFT_DATA_PORT GPIOA
#define TFT_DATA_SHIFT 0 // take the lower bits/pins 0..7
// The ESP32 and TFT the pins used for testing are:
#define TFT_RST PB3//PB0 // Reset pin, toggles on startup
#define TFT_CS PB4//PB1 // Chip select control pin (library pulls permanently low
#define TFT_DC PB5//PB3 // Data Command control pin - must use a pin in the range 0-31
#define TFT_WR PB6//PB4 // Write strobe control pin - must use a pin in the range 0-31
#define TFT_RD PB7//PB5 // Read strobe control pin
#define TFT_D0 PA0 // Must use pins in the range 0-31 for the data bus
#define TFT_D1 PA1 // so a single register write sets/clears all bits.
#define TFT_D2 PA2 // Pins can be randomly assigned, this does not affect
#define TFT_D3 PA3 // TFT screen update performance.
#define TFT_D4 PA4
#define TFT_D5 PA5
#define TFT_D6 PA6
#define TFT_D7 PA7
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
// #define SPI_FREQUENCY 1000000
// #define SPI_FREQUENCY 5000000
// #define SPI_FREQUENCY 10000000
// #define SPI_FREQUENCY 20000000
//#define SPI_FREQUENCY 27000000
// #define SPI_FREQUENCY 40000000
#define SPI_FREQUENCY 55000000 // STM32 SPI1 only (SPI2 maximum is 27MHz)
// #define SPI_FREQUENCY 80000000
// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 20000000
// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY 2500000
あまり良く解っていないのでFont、SPI関連も残してあります。
BluePillのSPI接続の場合、同じ"ILI9488"でスコアが「4000 msecs 」だったのでパラレル接続はやはり速いですね。最後まで見ていただきありがとうございました。