Display via U8glib and FlashMemory via SPI library How to use both parallel


I'm using a DOG-SPI Display with U8glib( and m2tklib) on a teensy 3.2.
The library works great works great with the Display and the Teensy.

Now I want to add a flash memory (S25FL164K0) to store data, that uses SPI as well.

Unfortunately, I was not able to get display and memory working at the same time. Flash on its own works as well as the display on its own. However, if I upload a sketch, employing both, the memory stops working at the moment the first data (u8g.firstPage() ) is printed to the Display.

For the memory I use the standard SPIFlash Library that comes with Arduino IDE 165-r5, that relies on the SPI library from the same distribution.
In principle it should be possible to access to different devices as shown in this example.

I was not able to determine, how the U8glib respective M2tklib connects to the SPI, else my idea would have been to try to rewrite that part of U8glib, that it works with the standard SPI-Library as well. Maybe someone can explain me how the u8glib works when it comes to SPI?

Another idea would be to employ completely different pins for the flash memory, as the Teensy offers alternate SPI pins. However, I don't know if it is technically possible to use two different sets of SPI pins at the same time.

I would like to provide some additional data, that might help you to suggest a solution to my problem.
The display is attached with this command:

U8GLIB_DOGM128 u8g(13, 11, 10, 9);// Initialisierung Display SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

The memory is attached via SPIFlash with:
SPIFlash flash(15, 0x0140);, that means CS# is Pin 15

The connections of the flash memory to the teensy are:
CS#=15, SCK=13, SO=12, SI=11

The reduced code looks as follows:

U8GLIB_DOGM128 u8g(13, 11, 10, 9);// Initialisierung Display SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
M2tk m2(&top_el_Start, m2_es_arduino, m2_eh_6bs, m2_gh_u8g_bf);
SPIFlash flash(15, 0x0140);
void setup() {
if (flash.initialize())
Serial.println("Init OK!");
Serial.println("Init FAIL!");      // Here everything is ok

m2_SetU8g(u8g.getU8g(), m2_u8g_box_icon);
m2.setFont(3, u8g_font_helvR24n);
m2.setFont(2, u8g_font_9x18_75r);
m2.setFont(1, u8g_font_7x13);
m2.setFont(0, u8g_font_6x12);
u8g.firstPage();                  // After this command the memory stops working correctly
do {
} while (u8g.nextPage());

I appreciate any comments.

Thank you for reading,


Was able to solve the problem myself with the help of this page.

How did you finally managed to solve it ?

I have the same problem (u8glib + SPI SRAM - 23LC1024) but I did not understood too much from the article.