GC9A01 LCD with IMU not working together...please assist

I have got a GC9A01 Round LCD display working with the GFX Library for Arduino on my Xiao BLE Sense. On a separate sketch, I have also got the IMU working using the Seed Arduino LSM6DS3, HighLevelExample. However, when I combine them, it compiles and uploads fine. However, it just gets stuck and nothing shows up on the display.

The problem occurs when I use myIMU.begin() with gfx->begin() at the same time. Turning one or the other off allows the other to work again.

After poking around, I found that if I change LSM6DS3 myIMU(I2C_MODE, 0x6A) to LSM6DS3 myIMU(SPI_MODE, 0x6A) the display and the unit runs again. However, when I use myIMU.readFloatAccelX(), it just gives me a static value of 1.87.

I should mention that I’m not using default pins for the GCA01, my setup is
Arduino_DataBus *bus = new Arduino_NRFXSPI(3 /DC/,2/CS/,5/SCK/,4/MOSI/,12/MISO/);
Arduino_GFX * gfx = new Arduino_GC9A01(bus, 1/DF_GFX_RST/,0/rotation/,true/IPS/);
Also, I’m powering the GCA01 from Xiao’s 3.3V pin.
I should also mention I’m very new to this, all this stuff.

Please help.
Thank you in advance.

So as I was poking around a little more I discovered some more details.
Suppose I call gfx->begin(); I can draw on the screen fine. But if I then call myIMU.begin() afterwards, the code that actually halts the program is the first instance of Wire.endTransmission() in the LSM6DS3Core::readRegister found in LSM6DS3.cpp. I also noticed when TARGET_SEED_XIAO_NRF52840_SENSE it defines Wire as Wire1. I wonder why Wire1 endTransmission is clashing with the gfx…

Now doing this the other way around. Suppose I run myIMU.begin() first, the program halts when I call any particular gfx draw function e.g. gfx->drawRect(…). Other non-draw functions are fine. The code that halts it is the first instance of writeAddrWindow(…) found in Arduino_GC9A01.cpp, Which calls _bus->writeC8D16D16(…) from Arudino_NRFXSPI.cpp in my case. In conclusion, writing to the display while Wire1 is ending transmission seems to be the problem. I just don’t have enough knowledge to determine why that is the case…

SOME SUCCESS! So I ordered an ST7789 1.3" Display and I tried the same thing with the same libraries, GFX_Library_for_Arduino and Seeed Arduino LSM6DS3. This time around I just connected to the display to the board SPI defaults e.g. MOSI 10 and SCLK 8. Again on different sketches, it works fine, but together it hangs. So I tried a new display library.

Finally, the display and the IMU worked together. Either the GFX_Library_for_Arduino library is incompatible or I’m not setting it up right.

I still need to get the GC9A01 Display working with the IMU as that is my preferred display though.

Solved. After some intensive research, I did the following

  1. Used the following library
    GitHub - PaintYourDragon/Adafruit_GC9A01A: Adafruit_GFX-compatible library for GC9A01A display driver

  2. I also added to the Seeed Arduino LSM6DS3 library.
    #include “pins_arduino.h”

then proceed to add the following before a wire.endTransmission call

if (digitalRead(I2C_SCL1)) == LOW || digitalRead(I2C_SDA1))

I read that it helps to avoid hangs in the wire library. Not the most elegant solution but the GC9A01 LCD now works with the IMU.

Thanks for spending our time in sharing the updates. Will be helpful for many.