Spark Logic

[SOLVED] ILI9431 problem

ENC28J60 SPDIP-28 Pinout
ILI9341 MSP3223 · 14-contact header Pinout

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 MiniMaple MiniDevelopment and computing boards…8MHz petertumler Thu Sep 24, 2015 10:58 am Hi, I’m trying to underclock a STM32F103 ( Maple Mini ) to 48MHz (for energy efficiency reasons). According to the datasheet .. The full…View in hardware catalog with an ENC28J60ENC28J60Communications, navigation, interfaces and RFID… have some compatibility issues with some routers so looks like I have to swap it to ENC28J60 . xebbmw Tue Sep 12, 2017 10:13 am [alce – Mon Sep 11, 2017 11:19 pm] – I have not pu…View in hardware catalog and MFRC522MFRC522Communications, navigation, interfaces and RFID…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 mess…View in hardware catalog 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 ENC28J60ENC28J60Communications, navigation, interfaces and RFID… have some compatibility issues with some routers so looks like I have to swap it to ENC28J60 . xebbmw Tue Sep 12, 2017 10:13 am [alce – Mon Sep 11, 2017 11:19 pm] – I have not pu…View in hardware catalog and MFRC522MFRC522Communications, navigation, interfaces and RFID…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 mess…View in hardware catalog 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 ENC28J60ENC28J60Communications, navigation, interfaces and RFID… have some compatibility issues with some routers so looks like I have to swap it to ENC28J60 . xebbmw Tue Sep 12, 2017 10:13 am [alce – Mon Sep 11, 2017 11:19 pm] – I have not pu…View in hardware catalog / MFRC522MFRC522Communications, navigation, interfaces and RFID…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 mess…View in hardware catalog .
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);
}

Replies20

Sat Feb 24, 2018 11:57 am

Looks to me that the rfid read for loop runs continuously hogging up resources, it should look something like this from the librarys example folder
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) return;                 // check if rfid card is present
if ( ! mfrc522.PICC_ReadCardSerial()) return;                   // read rfid card
mfrc522.PICC_HaltA();                                           // stop reading rfid card
if (rfid.uid.uidByte[0] != nuidPICC[0] ||
rfid.uid.uidByte[1] != nuidPICC[1] ||
rfid.uid.uidByte[2] != nuidPICC[2] ||
rfid.uid.uidByte[3] != nuidPICC[3] ) {
for (int i = 0; i < 4; i++) {                                   // setup loop to read 4 bytes from rfid card
readCard[i] = mfrc522.uid.uidByte[i];                         // read card ID byte
stringReadCard[i] = String(readCard[i], HEX);                 // save card ID byte as hex data
}
// convert rfid hex data to rfid string
String readID = stringReadCard[0] + stringReadCard[1] + stringReadCard[2] + stringReadCard[3];
if (readID != "") checkAccess(readID);
tftDisplay();
}
}

Sat Feb 24, 2018 10:52 pm

I agree with Manny. You really need to use millis() and profile the delta-time for the functions within loop vs the total time to perform 1 full loop. Find out what is hogging your code.

Ray

Sun Feb 25, 2018 7:55 am

Thanks guys.
I am away in Spain at the moment.
So I will try your suggestions when I get back in a couple of weeks time.

Thu Mar 08, 2018 5:29 pm

Hi guys.

I tried your suggestions and sadly it made no difference.
I found that if I remove all the rfid code in the main loop and just leave in the tft code then it still doesn’t work.
If I then comment out the MFRC522MFRC522Communications, navigation, interfaces and RFID…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 mess…View in hardware catalog .PCD_Init(); in the setup loop then the tft works ok.
Any more ideas ?

Thu Mar 08, 2018 5:57 pm

I’m not a big fan of this logic structure:
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) return;                 // check if rfid card is present
if ( ! mfrc522.PICC_ReadCardSerial()) return;                   // read rfid card
mfrc522.PICC_HaltA();                                           // stop reading rfid card

Thu Mar 08, 2018 8:21 pm

I remember lately there was a problem with ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog lib in Roger’s repo in another case, i don’t remember exactly which one.

You could give a try to the ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog lib from my repo (www.github.com/stevstrong/Arduino_STM32).

Fri Mar 09, 2018 7:43 am

Hi Ray.
I can’t rework the code as I removed all the card reader code and the tft display still didn’t work.
It was only when I removed the MFRC522MFRC522Communications, navigation, interfaces and RFID…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 mess…View in hardware catalog .PCD_Init(); from the setup loop that the tft display worked.

Hi Steve.
I will give your library a go later.
Thanks.

Fri Mar 09, 2018 11:18 am

Hi Steve.

When I use your Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog library I get the following compile error message.

arm-none-eabi-g++: error : (build.flags.optimize): No such file or directory

The original Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog library does not have this error.
Any idea what might be wrong ?

Fri Mar 09, 2018 12:24 pm

Did you take only the ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog lib files or the complete core?
Without a complete log of the Arduino IDE message window (verbose on) cannot figure it out.

Fri Mar 09, 2018 12:51 pm

Hi Steve.

I used the whole core.
I will give the ILI9431 library a go.
Thanks.

Fri Mar 09, 2018 1:37 pm

Hi Steve.

When I use just the ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM and GFX_AS libraries I get a bit further , but fail on a different error.

\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build4c2071f28635de9ec1f5b1d3003eb191.tmp\sketch\demo.ino.cpp.o"
In file included from C:\arduino-1.6.9\portable\sketchbook\maple\demo box\demo\demo.ino:29:0:

C:\arduino-1.6.9\portable\sketchbook\hardware\Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM/Adafruit_ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM.h: In member function 'void Adafruit_ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM::spiwrite16(uint16_t)':

C:\arduino-1.6.9\portable\sketchbook\hardware\Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM/Adafruit_ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM.h:148:48: error: 'class SPIClass' has no member named 'write16'

inline void spiwrite16(uint16_t c) { mSPI.write16(c); } // 8 bit mode

^

Using library SPI at version 1.0 in folder: C:\arduino-1.6.9\portable\sketchbook\hardware\Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\SPI
Using library UIPEthernet-master at version 2.0.6 in folder: C:\arduino-1.6.9\libraries\UIPEthernet-master
Using library rfid-master at version 1.2.0 in folder: C:\arduino-1.6.9\portable\sketchbook\libraries\rfid-master
Using library Adafruit_GFX_AS in folder: C:\arduino-1.6.9\portable\sketchbook\hardware\Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_GFX_AS (legacy)
Using library Adafruit_ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM in folder: C:\arduino-1.6.9\portable\sketchbook\hardware\Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog \STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog \libraries\Adafruit_ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog _STM (legacy)
exit status 1
Error compiling for board Maple MiniMaple MiniDevelopment and computing boards…8MHz petertumler Thu Sep 24, 2015 10:58 am Hi, I’m trying to underclock a STM32F103 ( Maple Mini ) to 48MHz (for energy efficiency reasons). According to the datasheet .. The full…View in hardware catalog .

Fri Mar 09, 2018 1:48 pm

On the first glance it seems that you are using a non-standard installation.
The Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog file structure should be located under:
C:/Users/<user>/Documents/Arduino/hardware/.
wherein your sketches are normally located under:
C:/Users/<user>/Documents/Arduino/
except the examples of specific libraries.

Beside that, I recommend to use Arduino IDE version 1.8.5 in a separate directory (for example:C:/Users/<user>/Downloads/).

Furthermore, I see that you need my SPI library as well which contains some extra functions compared to Roger’s core.

Fri Mar 09, 2018 2:16 pm

I ended up with the portable version of Arduino because I was having issues compiling any sketch.
My Arduino IDE runs on a XP VM.
I can’t remember the exact compile error message , but it was something to do with the file path being too long.
I am reluctant to upgrade my Arduino IDE at the moment as I might introduce even more issues.
I will just have to keep Googling my problem.
Thanks again for your help.

Fri Mar 09, 2018 2:19 pm

As an alternative, you could eventually use SPI1 for TFT alone, and the rest of devices on SPI2.

Fri Mar 09, 2018 4:42 pm

Yes that is another way.
Sadly I have already made the pcb with everything connected to SPI1.
I have been messing around with the MFRC522MFRC522Communications, navigation, interfaces and RFID…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 mess…View in hardware catalog library and find that if I comment out the following lines in the MFRC522MFRC522Communications, navigation, interfaces and RFID…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 mess…View in hardware catalog .PCD_Init(); then the tft display works.
PCD_WriteRegister(TModeReg, 0x80);	// TAuto=1; timer starts automatically at the end of the transmission in all communication modes at all speeds
PCD_WriteRegister(TPrescalerReg, 0xA9);	// TPreScaler = TModeReg[3..0]:TPrescalerReg, ie 0x0A9 = 169 => f_timer=40kHz, ie a timer period of 25µs.
PCD_WriteRegister(TReloadRegH, 0x03);	// Reload timer with 0x3E8 = 1000, ie 25ms before timeout.
PCD_WriteRegister(TReloadRegL, 0xE8);
PCD_WriteRegister(TxASKReg, 0x40);	// Default 0x00. Force a 100 % ASK modulation independent of the ModGsPReg register setting
PCD_WriteRegister(ModeReg, 0x3D);	// Default 0x3F. Set the preset value for the CRC coprocessor for the CalcCRC command to 0x6363 
PCD_AntennaOn();			// Enable the antenna driver pins TX1 and TX2 (they were disabled by the reset)

Obviously the rfid reader no longer works.
Any thoughts on why writing these values to the rfid card reader would cause issues with the tft display ?

Fri Mar 09, 2018 4:50 pm

It is maybe only the last function call which enables some pins.
Please check your pin mapping, maybe there is some overlapping between them and tft chip select or other pin reserved for tft.

Fri Mar 09, 2018 5:08 pm

Hi Steve.
Could you take a look at my original post , in there is an overview of how it is wired.
Can you spot anything wrong?

Fri Mar 09, 2018 5:15 pm

Ah, ok, I see now your pin mapping.
It looks fine to me.
I really have the feeling that the official ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog lib handles wrongly sometimes the chip select.
For testing, please try to add after each tft function call group a TFT_CS release line:
tft.funct1(); // pseudo code
tft.func2(); // pseudo code
digitalWrite(TFT_CS, HIGH); // real code

Fri Mar 09, 2018 5:31 pm

Tried that and still no joy.
Looks like I am going to have to go back to the drawing board with this one.
Thanks again for all your help.

Post a reply

Optional · up to 10 MiB