Nano 33 BLE rev 2 and TFT_eSPI library

I'm trying to modify the setup files of the TFT_eSPI library so that the Nano 33 BLE rev 2 can communicate with the ILI9341 display driver on a 240 x 320 TFT display. The Nano nRF52840 processor is not listed in the setup files, so a sort of generic ILI9341 driver has to be defined - but how? It seems like the TFT_eSPI library defaults to the Raspberry Pi RP2040 processor even though it is commented out // in the setup file. Has anyone tried this and found a solution? Thanks.

Have you considered any other library. I can't do research now but maybe Adafruit supports your setup of board and ILI9341.

Maybe the Adafruit library is a good option – thanks.
I have discussed the issue with AI Gemini a couple of times and Gemini is convinced that it should be possible to use the TFT_eSPI library. However, Gemini has not been able to come up with a solution that works.

You can try it, the settings file User_Setup.h

#define USER_SETUP_INFO "User_Setup"
//#define ILI9341_2_DRIVER // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
#define ILI9341_DRIVER     // Generic driver for common displays
 #define TFT_HEIGHT 320    // ST7789 240 x 320
 #define TFT_HEIGHT 240    // GC9A01 240 x 240

// SPI
//#define PIN_SPI_MISO  (12u)
//#define PIN_SPI_MOSI  (11u)
//#define PIN_SPI_SCK   (13u)
//#define PIN_SPI_SS    (10u)
//static const uint8_t SS   = PIN_SPI_SS;   // SPI Slave SS not used. Set here only for reference.
//static const uint8_t MOSI = PIN_SPI_MOSI;
//static const uint8_t MISO = PIN_SPI_MISO;
//static const uint8_t SCK  = PIN_SPI_SCK;

// Nano 33 BLE REV2 Module
 #define TFT_MISO 12
 #define TFT_MOSI 11
 #define TFT_SCLK 13
 #define TFT_CS  -1 //10 // Chip select control pin
 #define TFT_DC 2  // Data Command control pin
 #define TFT_RST -1 //4 // Reset pin (could connect to RST pin)
                   // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
  #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_READ_FREQUENCY 1000000
 #define SPI_TOUCH_FREQUENCY 2500000
 //#define USE_HSPI_PORT

Thanks Victor_UA6EM,
I modified the User_Setup.h file first by commenting all lines,//, and then inserting your suggestion.
I opened the very simple example sketch TFT_Elipse and selected my Nano 33 BLE rev 2 board on COM 3. The Arduino IDE compiler again listed many many errors and talking about TFT_eSPI_RP2040.c errors. To me it seems that the TFT_eSPI library defaults to the Raspberry Pi RP2040 processor. Maybe the TFT_eSPI library only works with the listed boards.

Yes, I was in a hurry too, I thought the limitation was only on the frequency of the SPI
The Adafruit library runs on SPI software.

Reading the library documentation, I think it should work with any Arduino compatible 32-bit board, including nRF52840. It just won't be as optimised as with the listed boards, and may not perform as fast, for similar clock speeds. The documentation mentions Teensy boards for example:

For other (generic) processors only SPI interface displays are supported and the slower Arduino SPI library functions are used by the library. Higher clock speed processors such as used for the Teensy 3.x and 4.x boards will still provide a very good performance with the generic Arduino SPI functions.

nRF52840 has a similar clock speed to Teensy 3.2.

It's also necessary to make some changes in the library's configuration file. Is it possible that in your file it is configured in some way that makes the library think the processor is RP2040? Otherwise I think it should treat your Nano nRF52840 as a "generic" Arduino. If that's not happening, then it may be the library has a bug.

Not a "driver" but maybe a configuration file. There are many example config files in the library but none of them seem to be for a "generic" Arduino compatible board. I don't know how you make one. But my guess it that you have for some reason got one of the RP2040 configuration files active.

There is a discussion page and a page for raising bugs on the library documentation page. The discussion page may be a good place to ask questions.

Thanks PaulRB,
In the User_Setup_Select.h file the only line active is #include <User_Setup.h> . Alle other are commented out //, and they all refer to specific boards/processors. So as I understand it, the compiler should go directly to the User_Setup.h file. Here the parameters are set, but the compiler still reports errors as if the RP2040 is selected.
In the TFT_eSPI README.txt file you can read the following:
"This is a stand-alone library that contains both graphics functions
and the TFT chip driver library. It supports the ESP8266, ESP32,
STM32 and RP2040 processors with performance optimised code. Other
Arduino IDE compatible boards are also supported but the library
then uses generic functions which will be slower. The library uses
32-bit variables extensively so this will affect performance on 8
and 16-bit processors."
So it should work according to Bodmer, but how? Maybe Bodmer is listening in?

To contact someone on this forum, put @ symbol before their name like this @bodmer

However, Bodmer has not been contributing to the forum for a number of years now.

That's why I suggested the discussion page linked to on the library page.

Thanks PaulRB,
I got the Adafruit_ILI9341 library to work, but it is very slow. I will see if it is OK. If not I guess that I will need a faster processor like the ESP8266 or ESP32.
Thanks everyone!

Maybe you are using software SPI instead of hardware SPI? Software SPI is slow, whatever board you run it on. It is not the nRF52840 that is slow.

If you are passing the pin numbers for MOSI & SCK to the object constructor, it is probably using software SPI.

It can use either software or hardware SPI, you configure that in your code:

Adafruit_ILI9341 myTFT(myCSpin, myDCpin, myMOSIpin, mySCLKpin, myRSTpin);

The above will use software SPI (slow).

Adafruit_ILI9341 myTFT(myCSpin, myDCpin, myRSTpin);

The above will use hardware SPI (fast).

Thanks PaulRB
I did use the full pin description, so I just changed it to the three you mentioned: CS, DC and RST. However it is hard to tell whether it is faster to clear the screen for example. Maybe a little. According to the Arduino documentation the Nano 33 BLE rev 2 has real SPI hardware, but I guess it has to be properly utillized/setup in the Adafruit_ILI9341 library.

You could try

SPI.begin(32000000);

but I have now read some articles that say SPI speed is not great on Nano 33 BLE, so it might not even work correctly at that speed.

If so, I take back what I said earlier about the nRF52840 not being slow. It seems it's SPI hardware, at least, is pretty slow for some reason.

Thanks PaulRB,
I tried the add the SPI.begin(32000000), but got the compile error: "error: no matching function for call to 'arduino::MbedSPI::begin(int)'".
I guess you are right that the Nano 33 BLE rev 2 is rather slow on its SPI bus.
If it ends up being too slow I must change platform to something faster.
Thanks for your time Paul

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.