Spark Logic

[SOLVED] ILI9431 problem

lapgoch Sat Feb 24, 2018 2:39 am

Hi.
I am looking for some help.
I have an existing sketch that works ok.
The sketch is used to unlock a door with a rfid card.
It uses a Maple Mini with an ENC28J60 and MFRC522 on the SPI bus.
I would like to add a ILI9431 tft display to show some door entry messages.
When I add the tft display to the same SPI bus and run a basic tft sketch only , the tft display works ok.
When I add the same basic tft sketch to my door lock sketch and run the total sketch I have problems.
The problem is that the ENC28J60 and MFRC522 still work ok , but very slowly.
The ILI9431 tft display only updates one pixel at a time incredibly slowly.
Does anyone know why the ILI9431 is conflicting with the ENC28J60 / MFRC522.
Here is the tft sketch

// tft screen setup
#define CS_TFT PA8
#define DC_TFT PB12
#define RST_TFT PA1
#include <Adafruit_GFX_AS.h>
#include <Adafruit_ILI9341_STM.h>
Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(CS_TFT, DC_TFT, RST_TFT);

void setup() {
tft.begin();
tft.setRotation(1);
}

void loop() {
tftDisplay();

}

void tftDisplay() {
tft.setTextSize(1);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.drawString("01234",0,0,7);
tft.drawString("56789",0,120,7);
delay(1000);

tft.setTextSize(2);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.drawString("1234",0,0,7);
tft.drawString("Lapgoch",50,140,4);
delay(1000);
}

Replies

impulse Sat Mar 10, 2018 5:10 am

On other platforms I have seen similar issues when SPI transaction support was not enabled.
I haven’t looked into the STM32 core enough to know whether this would be applicable here, but did note that STM32Fx/libraries/SPI/src/SPI.h has transaction support disabled by default.

#define SPI_HAS_TRANSACTION

stevestrong Sat Mar 10, 2018 8:27 am

Even if this define is not active, I always use SPI.beginTransaction(…) when SPI is involved. It works.
But this has nothing to do with the original issue.

lapgoch Fri Mar 23, 2018 7:14 pm

Hi.

After much messing about to create a new win7 VM with arduino IDE 1.8.5 with a standard install .
I still had exactly the same issue , the mfrc522 card reader and ili9431 display just would not work together on the same SPI bus.
I finally ditched the libraries <Adafruit_GFX_AS.h> and <Adafruit_ILI9341_STM.h> and just used <Adafruit_GFX.h> and <Adafruit_ILI9341.h>
These worked perfectly , slow but fine for my application.
So there seems to be a conflict with Adafruit STM library and the mfrc522 library.
Being a mere mortal I have no idea how to fix the conflict.
Maybe someone of god like status could shed some light on it.

stevestrong Fri Mar 23, 2018 10:50 pm

There is a PR on GitHub about the problems with the graphics library functions leaving the SPI bus in 16 bit mode, which is most probably the cause of this problem.
You can try to execute
SPI.beginTransaction(SPISettings(18000000, MSBFIRST, SPI_MODE0, DATA_SIZE_8BIT));

lapgoch Sat Mar 24, 2018 6:43 am

Hi Steve.

Many thanks , you are a star.
Everything is working great now.
I had played around with all different settings for SPI.beginTransastion with no joy.
I did not know about the 8 / 16 bit settings.

Thanks also to Roger Clarke for having similar SPI multi device issues and looking into it.

Sign in to reply