I modify the library of iwalpola the Adafruit ILI9341 8bit STM to work with the ILI9481, I leave the link from mega
https://mega.nz/#!59NmzIRA!EB3XwPoYjhPA … XVYZB7A6iQ
bye
Ideally this should be put on github etc where people can easily view and download the source, rather than a zip
Just one thing, I spotted a typo. Pin D1 should go to PA1 and not to PC1.
I’m running the graphicstest sketch and text in portrait looks OK but when it is rotated (landscape) it looks mirrored.
I modify the library of iwalpola the Adafruit ILI9341 8bit STM to work with the ILI9481, I leave the link from mega
https://mega.nz/#!59NmzIRA!EB3XwPoYjhPA … XVYZB7A6iQ
bye
I’m running the graphicstest sketch and text in portrait looks OK but when it is rotated (landscape) it looks mirrored.
i am quite new to this, but i have already some arduino shileds here. Now im experimenting with the stm32f103c6. Especially for tft it might be faster than the mega…
I have this shield: https://www.mikrocontroller.net/attachm … e_SPEC.pdf saying its a ili9481.. but i think its a HX8357B?!
or a
http://shop.boxtec.ch/tft-lcd-shield-fo … 42762.html shield, which is more a ili9481.
..and a blue pill.
But i dont know which pin at the tftshield should go to which pin at the stm. touch is not necessary. Can you give me a quickstart somehow? Maybe SPI?
Thanks, Mike.
OTOH, recent “similar looking Shields” contain an ILI9481. The clue is written on the part number printed on the anti-static bag that the Shield came with.
The second Shield does contain ILI9481. And since that Shield is readable, you can confirm by reading reg(0xBF)
If you want to distinguish between HX8357-B and ILI9481, there are some minor differences in Manufacturer Registers.
David.
I have STM32F103C8T6 and 3.2″ TFTLCD Shield for Arduino Mega2560 Driver-ILI9481. With connection and programming there are no problems. Problem with color of the screen. After loading of the program the screen becomes blue. Inversion of chromaticity doesn’t solve problems. I assume a problem in initialization of the display but as where to change I don’t know. I ask for suggestions. As where to correct???
https://yadi.sk/d/lS0rNl9V3NJYJ9
– the used TFT LCD lib (link?)
– the used core (Arduino_STM32?)
– the used sketch (link?)
– on which OS are you developing.
Check your wiring, it seems to me that red and green colors are missing.
ILI9481 320*480 3.5
the used core (Arduino_STM32?)
“generic STM32F103C series”
the used sketch (link?) #include "Adafruit_GFX.h" #include "Adafruit_ILI9481_8bit_STM.h" // Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC void setup() { Serial.begin(115200); tft.begin(); } void loop() { }
[code]
//#include "gfxfont.h"
Adafruit_ILI9481_8bit_STM tft = Adafruit_ILI9481_8bit_STM();
// If using the breakout, change pins as desired
//Adafruit_ILI9481_8bit_STM tft = Adafruit_ILI9481_8bit_STM(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
Serial.println("ILI9481 Test!");
//tft.invertDisplay(true);
tft.setRotation(3); //Устанавливаем заставку
tft.fillScreen(ILI9481_BLUE);
tft.setCursor(10, 10);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(3);
tft.print("Adafruit_ILI9481_8bit_STM");
tft.setCursor(10, 50);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(3);
tft.print("3.2 TFTLCD Shield for Mega 2560");
tft.setCursor(10, 140);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(7);
tft.print("TEST");
//tft.setCursor(170, 170);
tft.print("ILI9481");
delay(200);
tft.setCursor(70, 230);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(5);
tft.print("VERSION ");
tft.print("V1.1");
tft.setCursor(190, 280);
tft.print("2017");
delay(30000);
tft.fillScreen(ILI9481_BLACK);
tft.fillScreen(ILI9481_BLUE);
tft.setCursor(170, 270);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(5);
tft.print("BLUE");
delay(3000);
tft.fillScreen(ILI9481_WHITE);
tft.setCursor(170, 270);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(5);
tft.print("WHITE");
delay(3000);
tft.fillScreen(ILI9481_BLACK);
tft.setCursor(170, 270);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(5);
tft.print("BLACK");
delay(3000);
tft.fillScreen(ILI9481_RED);
tft.setCursor(170, 270);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(5);
tft.print("RED");
delay(3000);
tft.fillScreen(ILI9481_ORANGE);
tft.setCursor(170, 270);
tft.setTextColor(ILI9481_WHITE,ILI9481_BLUE);
tft.setTextSize(5);
tft.print("ORANGE");
delay(3000);
– it looks like you are using an 8 bit library for a 16 bit parallel bus driven display. In this case it is normal that you at least one color is missing.
– how (which pins) did you connect the blue pill to the LCD? Photo of the hardware setup?
//Port data |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
//Pin stm32 |PA7|PA6|PA5|PA4|PA3|PA2|PA1|PA0|
//Control pins |RD |WR |RS |CS |RST|
//Pin stm32 |PB4|PB5|PB6|PB7|PB8|
#define TFT_RD PB4
#define TFT_WR PB5
#define TFT_RS PB6
#define TFT_CS PB7
#define TFT_RST PB8
You have to comment out (disable) this line if you are not using FSMC.
But unfortunately:
Arduino: 1.8.4 (Windows 10), Плата:"Generic STM32F103C series, STM32F103CB (20k RAM. 128k Flash), STM32duino bootloader, 72Mhz (Normal), Smallest (default)"
Изменены опции сборки, пересобираем все
In file included from C:\Users\User\Documents\Arduino\libraries\Adafruit_TFTLCD_16bit_STM32-master\src/Adafruit_TFTLCD_16bit_STM32.h:56:0,
from C:\Users\User\Documents\Arduino\libraries\Adafruit_TFTLCD_16bit_STM32-master\examples\graphicstest\graphicstest.ino:7:
C:\Users\User\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\system/libmaple/include/libmaple/fsmc.h:47:2: error: #error "FSMC is unavailable on your MCU"
#error "FSMC is unavailable on your MCU"
to this:
//#define USE_FSCM 1 // use FSCM interface instead raw GPIO access// IMPORTANT: SEE COMMENTS @ LINE 15 REGARDING SHIELD VS BREAKOUT BOARD USAGE.
// Graphics library by ladyada/adafruit with init code from Rossum
// MIT license
#ifndef _ADAFRUIT_TFTLCD_16BIT_STM32_H_
#define _ADAFRUIT_TFTLCD_16BIT_STM32_H_
#define PROGMEM
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
#include <Adafruit_GFX.h>
//#define USE_FSCM 1 // use FSCM interface instead raw GPIO access
//#define USE_MAPLE_MINI_PINOUT // for use with maple mini
/*****************************************************************************/
// LCD controller chip identifiers
#define ID_932X 0
#define ID_7575 1
#define ID_9341 2
#define ID_HX8357D 3
#define ID_UNKNOWN 0xFF
/*****************************************************************************/
#ifndef TFTWIDTH
#define TFTWIDTH 320
#define TFTHEIGHT 480
#endif
// Initialization command tables for different LCD controllers
#define TFTLCD_DELAY 0xFF
// For compatibility with sketches written for older versions of library.
// Color function name was changed to 'color565' for parity with 2.2" LCD
// library.
#define Color565 color565
/*****************************************************************************/
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
/*****************************************************************************/
// Define pins and Output Data Registers
/*****************************************************************************/
#ifdef USE_FSCM
// use FSCM peripheral
#include <libmaple/fsmc.h>
#define CD_COMMAND
#define CD_DATA
#define CS_ACTIVE
#define CS_IDLE
#define CS_ACTIVE_CD_COMMAND
#define lcdCommand (*fsmcCommand)
#define lcdData (*fsmcData)
// set pins to output the 8 bit value
#define writeCmd(d) { lcdCommand = d; } //(d&0x00FF); }
#define writeData(d) { lcdData = d; }
#define WR_STROBE writeData(color)
#else
// use normal GPIO access
#include <libmaple/gpio.h>
// Port data bits D0..D16:
#if defined (__STM32F1__)
#define TFT_DATA_PORT GPIOA
//#elif defined (__STM32F4__)
// #define TFT_DATA_PORT (&GPIOD)
#endif
#define TFT_DATA_IO_PORT 'A'
//Control pins |RD |WR |RS |CS |RST|
#if defined (__STM32F1__)
#define TFT_CNTRL_PORT GPIOB
//#elif defined (__STM32F4__)
// #define TFT_CNTRL_PORT (&GPIOC)
#endif
#define TFT_CNTRL_IO_PORT 'B'
//#define TFT_RD_BIT 5
#define TFT_RS_BIT 6
#define TFT_WR_BIT 5
#define TFT_CS_BIT 7
#define Port2Pin(port, bit) ((port-'A')*16+bit)
//#define TFT_RD_PIN Port2Pin(TFT_CNTRL_IO_PORT, TFT_RD_BIT)
#define TFT_WR_PIN Port2Pin(TFT_CNTRL_IO_PORT, TFT_WR_BIT)
#define TFT_RS_PIN Port2Pin(TFT_CNTRL_IO_PORT, TFT_RS_BIT)
#define TFT_CS_PIN Port2Pin(TFT_CNTRL_IO_PORT, TFT_CS_BIT)
#define RST_ACTIVE digitalWrite(TFT_RST_PIN, LOW)
#define RST_IDLE digitalWrite(TFT_RST_PIN, HIGH)
#if 0 // used TFT does not support RD operation
#define RD_ACTIVE digitalWrite(TFT_RD_PIN, LOW)
#define RD_IDLE digitalWrite(TFT_RD_PIN, HIGH)
#endif
#if 0
// use old definition, standard bit toggling, low speed
#define WR_ACTIVE digitalWrite(TFT_WR_PIN, LOW) //
#define WR_IDLE digitalWrite(TFT_WR_PIN, HIGH) //
#define CD_COMMAND digitalWrite(TFT_RS_PIN, LOW)
#define CD_DATA digitalWrite(TFT_RS_PIN, HIGH)
#define CS_ACTIVE digitalWrite(TFT_CS_PIN, LOW)
#define CS_IDLE digitalWrite(TFT_CS_PIN, HIGH)
#define CS_ACTIVE_CD_COMMAND { CS_ACTIVE; CD_COMMAND; }
#else
// use fast bit toggling, very fast speed!
extern gpio_reg_map * cntrlRegs;
#define WR_ACTIVE gpio_clear_dev_bit(TFT_CNTRL_PORT, TFT_WR_BIT) //digitalWrite(TFT_WR_PIN, LOW)//
#define WR_IDLE digitalWrite(TFT_WR_PIN, HIGH)//gpio_set_dev_bit(TFT_CNTRL_PORT, TFT_WR_BIT) //
#define CD_COMMAND gpio_clear_dev_bit(TFT_CNTRL_PORT, TFT_RS_BIT) //{ cntrlRegs->BSRRH = BIT(TFT_RS_BIT); } //
#define CD_DATA gpio_set_dev_bit(TFT_CNTRL_PORT, TFT_RS_BIT) //{ cntrlRegs->BSRRH = BIT(TFT_RS_BIT); } //
#define CS_ACTIVE gpio_clear_dev_bit(TFT_CNTRL_PORT, TFT_CS_BIT) //{ cntrlRegs->BSRRL = BIT(TFT_CS_BIT); } //
#define CS_IDLE gpio_set_dev_bit(TFT_CNTRL_PORT, TFT_CS_BIT) //{ cntrlRegs->BSRRH = BIT(TFT_CS_BIT); } //
#define CS_ACTIVE_CD_COMMAND { cntrlRegs->BSRRH = BIT(TFT_CS_BIT)|BIT(TFT_RS_BIT); }
#endif
#define WR_STROBE { WR_ACTIVE; WR_IDLE; }
extern gpio_reg_map * dataRegs;
#if 0 // used TFT cannot be read
extern uint8_t read8_(void);
#define read8(x) ( x = read8_() )
#define setReadDir() { for (uint8 i = 0; i<16; i++) { pinMode(Port2Pin(TFT_DATA_IO_PORT,0)+i, OUTPUT); } } // set the bits as input
#endif // used TFT cannot be read
#define setWriteDir() { for (uint8 i = 0; i<16; i++) { pinMode(Port2Pin(TFT_DATA_IO_PORT,0)+i, OUTPUT); } } // set the bits as output
// set pins to output the 8 bit value
#define writeData_(d) { dataRegs->ODR = d;}
//#define writeCmd(d) { writeData_(d&0x00FF); WR_STROBE; }
#define writeCmd(d) { writeData_(d); WR_STROBE; }
#define writeData(d) { writeData_(d); WR_STROBE; }
#endif // USE_FSCM
#define TFT_RST_PIN PB8
/*****************************************************************************/
#define swap(a, b) { int16_t t = a; a = b; b = t; }
/*****************************************************************************/
class Adafruit_TFTLCD_16bit_STM32 : public Adafruit_GFX {
public:
//Adafruit_TFTLCD_8bit_STM32(uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t rst);
Adafruit_TFTLCD_16bit_STM32(void);
void begin(uint16_t id = 0x9341);
void drawPixel(int16_t x, int16_t y, uint16_t color);
void drawFastHLine(int16_t x0, int16_t y0, int16_t w, uint16_t color);
void drawFastVLine(int16_t x0, int16_t y0, int16_t h, uint16_t color);
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t c);
void fillScreen(uint16_t color);
void reset(void);
void setRegisters8(uint8_t *ptr, uint8_t n);
void setRegisters16(uint16_t *ptr, uint8_t n);
void setRotation(uint8_t x);
// These methods are public in order for BMP examples to work:
void setAddrWindow(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
void invertDisplay(boolean i),
pushColors(uint16_t *data, int16_t len, boolean first),
drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t * bitmap);
#if 0 // used TFT cannot be read
uint16_t readPixel(int16_t x, int16_t y),
readID(void);
#endif
private:
void init(),
flood(uint16_t color, uint32_t len);
uint8_t driver;
};
extern uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
#if 0 // used TFT cannot be read
extern uint16_t readReg(uint8_t r);
extern uint32_t readReg32(uint8_t r);
#endif
static inline void writeCommand(uint16_t c) __attribute__((always_inline));
static inline void writeCommand(uint16_t c) {
CS_ACTIVE_CD_COMMAND;
writeCmd(c);
}
extern void writeRegister8(uint16_t a, uint8_t d);
extern void writeRegister16(uint16_t a, uint16_t d);
//extern void writeRegister24(uint16_t a, uint32_t d);
extern void writeRegister32(uint16_t a, uint32_t d);
//extern void writeRegister32(uint16_t a, uint16_t d1, uint16_t d2);
extern void writeRegisterPair(uint16_t aH, uint16_t aL, uint16_t d);
#endif
Currently getting some strange linker error, hope I can solve the issue today.
Notes:
– reading of the ID is not implemented, so you have to set the identifier to a fixed value (0x9341 or 0x9328).
– for F103 I defined GPIOB (bits0..15) as data port, because GPIOA has some reserved pins for USB which I think is essential to keep it work.
The problematic pin is only PB2 which is not lead to board pins, but only to BOOT1 jumper (middle pin).
In order to use this pin you have to shortcut R4 on the back side of the board which is connected between the F103 chip and the BOOT1 jumper.
This resistor is 100Kohm so that the PB2 output will not work unless you solder a bridge over this resistor (shortcut).
– the control pins must all be mapped to the same GPIO, my default is GPIOA, but you could also use GPIOC (PC13..15).
– color565() is now (set back as) member of the Adafruit_TFTLCD_16bit_STM32 class. The graphicstest has been updated accordingly.
This means that you have to use now “tft.color565()” instead of “color565()”.
Building is error/warning-less, but I did not test the functionality, because it would cost me a lot of time to re-wire the LCD onto blue pill.
So I cannot give any guarantee for that.
Please try it and let me know if it works.
Use:
B0-B15 (B2 redone)
#define Tft_wr_pin PA1
#define Tft_rs_pin PA2
#define Tft_cs_pin PA3
#define Tft_rst Pin PC15
pinMode(PB0, OUTPUT);
digitalWrite(PB0, LOW);
delay(500);
digitalWrite(PB0, HIGH);
delay(500);I also burned one of my ILI9328 display, although only soldered some of the board pins. It seems that they are quite sensitive to heat.
I have a prototype/adapter board which I made which will work with this tft driver as it uses the same data and control lines. My problem is that I would dearly love access to more ADC pins but as PA0 to PA7 are ADC and are used for tft data, I’m hoping to design a new board which I can connect this module to https://www.aliexpress.com/item/Mini-ve … 0.0.P05Hai
I’m not an expert low level programmer and changing the driver to use PC0 to PC7 for tft data is above my skill set. Can anyone please advise if it can be done and if so, how.
Regards, Steve.
FSMC works 8bit as well.
and changing the driver to use PC0 to PC7 for tft data
It seems you have to change (in Adafruit_ILI9481_8bit_STM.h) the
#define TFT_DATA GPIOA
I have a number of tft shields with standard uno connectors so I really want to make use of them rather than buying different ones.
If all I have to do is declare #define TFT_DATA GPIOC, then I’ll be happy but surely it’s not that easy is it?
Steve.
I may not understand your request right, but please try this.
https://github.com/nopnop2002/STM32_TFT_8bit
I tested my STM32F103 RBT6 & 3.5 inch 320*480 ILI9481 TFT.
It’s work fine using GPIOC.
Hi, I am trying to interface my generic F407 board to a TFT LCD utilizing nt35310. It seems to be compatible to the ili9481, however, my TFT LCD is using only 8Bit parallel. Using your library and FSMC, I am getting displays but the coordinates are wrong and colors are wrong obviously because of the loss in the 8 higher order bits. I am pretty happy because I am getting some displays from the LCD, I have previously tried using Stm32 HAL code but am not getting anything from the LCD at all, at least your library gave me some displays.
I have tried changing the FSMC to 8bits in the libmaple library, but then the LCD went dead right after the change. I am not sure what went wrong, hopefully you can provide some insights.
[flodejr – Mon Jan 15, 2018 1:48 pm] –
I have tried changing the FSMC to 8bits in the libmaple library, but then the LCD went dead right after the change. I am not sure what went wrong, hopefully you can provide some insights.
Please provide detailed information what and how exactly have you tried.
I am not sure if it is enough only to set MWID = 00 (8 bit) by using flag [FSMC_BCR_MWID_8BITS]. It also may be necessary to split the 16 bit access into two successive 8 bit accesses by software, if the hardware doesn’t do that.
So basically do
*fsmcData = <high_nibble>;
*fsmcData = <low_nibble>;
[stevestrong – Mon Jan 15, 2018 2:35 pm] –
Please provide detailed information what and how exactly have you tried.I am not sure if it is enough only to set MWID = 00 (8 bit) by using flag [FSMC_BCR_MWID_8BITS]. It also may be necessary to split the 16 bit access into two successive 8 bit accesses by software, if the hardware doesn’t do that.
So basically do
*fsmcData = <high_nibble>;
*fsmcData = <low_nibble>;
Only do one change at a time, and then check the effect.
I think you should not change the fsmcData address.
I haven’t tried in 8 bit mode, but I could give it a try, just that time is missing…
I managed to get the code working in 8 bit FSMC mode, supporting 3.5inch TFT module with NT35310 chipset. Modifications done :
1) Changed libmaple/fsmc.h to include switch between FSMC16 bit mode and FSMC 8 bit mode
#ifdef _FSMC16_
volatile uint16_t * fsmcCommand;
volatile uint16_t * fsmcData;
#endif
#ifdef _FSMC8_
volatile uint8_t * fsmcCommand;
volatile uint8_t * fsmcData;
#endif
I will adapt my repo to reflect these changes.
[stevestrong – Tue Jan 16, 2018 7:51 am] –
Well done!
I will adapt my repo to reflect these changes.
As a side note, the LCD works even in 16 bit FSMC mode, switching to 8bit FSMC just saves some pins for other purposes. However, I have some issues now, I ported part of the code to stm32cubeMX and it doesn’t work!!!
HAL is really Hell, nothing works
![]()
My libmaple repo, as an alternative for Roger’s official repo, offers most of functionality for F4: http://stm32duino.com/viewtopic.php?f=39&t=1976.
[stevestrong – Tue Jan 16, 2018 12:28 pm] –
Why do you need HAL?
My libmaple repo, as an alternative for Roger’s official repo, offers most of functionality for F4: http://stm32duino.com/viewtopic.php?f=39&t=1976.
There is no DCMI implementation in stm32duino as far as I know. Anyway, I managed to get the HAL code working as well. Next to add DCMI camera.
[flodejr – Tue Jan 16, 2018 2:41 pm] –
There is no DCMI implementation in stm32duino as far as I know.
That is true, Arduino_STM32 (libmaple core) lacks DCMI functionality.
I might add it when I get my next free time slot.
I’ll put it as one of the next tasks.
[stevestrong – Tue Oct 03, 2017 6:52 pm] –
[url=https://github.com/stevstrong/Adafruit_ … TM32.h#L80]data port[/ur] In order to use this pin you have to shortcut R4 on the back side of the board which is connected between the F103 chip and the BOOT1 jumper.
This resistor is 100Kohm so that the PB2 output will not work unless you solder a bridge over this resistor (shortcut)
So to follow up with the post steve is there other way aside from you mentioned above , I have Hx_3857 tft lcd using stm32f103 , core from roger your library looks work to me because the serial outputs . Hoping you can help me
[nyx123 – Mon Jan 22, 2018 1:48 am] –
So to follow up with the post steve is there other way aside from you mentioned above , I have Hx_3857 tft lcd using stm32f103 , core from roger your library looks work to me because the serial outputs . Hoping you can help me
HX8357D should be supported.
What have you tried and what is your problem exactly?

