Can't use an SPI LCD screen with arduino Nicla

Hi,
I'am using an arduino Nicla Vision with a waveshare 1.28inc LCD screen module.
The module is using SPI and GC9A01.

I found a demo for this type of driver : GitHub - carlfriess/GC9A01_demo: Arduino demo of the GC9A01 driver for a 240x240 display
And I changed the Pin atttribution for using the SPI4 bus of the arduino Nicla Vision. It compile without error and seems running but I have no results other than a black screen. I checked my wiring and my connections but I doesn't seem to come from this.

Any ideas ? I can't find a lot of examples about GPIO pin attribution with arduino Vision.

Thanks for your help.

This is the code modified for my Nicla :

#include <SPI.h>
#include "GC9A01.h"

#define TFT_BL PG_12
#define MOSI PE_14
#define CLK PE_12
#define CS PE_11
#define DC PG_1
#define RST PA_9

void GC9A01_set_reset(uint8_t val) {
    digitalWrite(RST, val);
}

void GC9A01_set_data_command(uint8_t val) {
    digitalWrite(DC, val);
}

void GC9A01_set_chip_select(uint8_t val) {
    digitalWrite(CS, val);
}

void GC9A01_spi_tx(uint8_t *data, size_t len) {
    while (len--) {
        SPI.transfer(*data);
        data++;
    }
}

void GC9A01_delay(uint16_t ms) {
    delay(ms);
}

void setup() {
    
    pinMode(RST, OUTPUT);
    pinMode(DC, OUTPUT);
    pinMode(CS, OUTPUT);
    SPI.begin();

    GC9A01_init();
    struct GC9A01_frame frame = {{0,0},{239,239}};
    GC9A01_set_frame(frame);
    
}

void loop() {

    uint8_t color[3];

    // Triangle
    color[0] = 0xFF;
    color[1] = 0xFF;
    for (int x = 0; x < 240; x++) {
        for (int y = 0; y < 240; y++) {
            if (x < y) {
                color[2] = 0xFF;
            } else {
                color[2] = 0x00;
            }
            if (x == 0 && y == 0) {
                GC9A01_write(color, sizeof(color));
            } else {
                GC9A01_write_continue(color, sizeof(color));
            }
        }
    }

    delay(1000);

    // Rainbow
    float frequency = 0.026;
    for (int x = 0; x < 240; x++) {
        color[0] = sin(frequency*x + 0) * 127 + 128;
        color[1] = sin(frequency*x + 2) * 127 + 128;
        color[2] = sin(frequency*x + 4) * 127 + 128;
        for (int y = 0; y < 240; y++) {
            if (x == 0 && y == 0) {
                GC9A01_write(color, sizeof(color));
            } else {
                GC9A01_write_continue(color, sizeof(color));
            }
        }
    }

    delay(1000);

    // Checkerboard
    for (int x = 0; x < 240; x++) {
        for (int y = 0; y < 240; y++) {
            if ((x / 10) % 2 ==  (y / 10) % 2) {
                color[0] = 0xFF;
                color[1] = 0xFF;
                color[2] = 0xFF;
            } else {
                color[0] = 0x00;
                color[1] = 0x00;
                color[2] = 0x00;
            }
            if (x == 0 && y == 0) {
                GC9A01_write(color, sizeof(color));
            } else {
                GC9A01_write_continue(color, sizeof(color));
            }
        }
    }

    delay(1000);

    // Swiss flag
    color[0] = 0xFF;
    for (int x = 0; x < 240; x++) {
        for (int y = 0; y < 240; y++) {
            if ((x >= 1*48 && x < 4*48 && y >= 2*48 && y < 3*48) ||
                (x >= 2*48 && x < 3*48 && y >= 1*48 && y < 4*48)) {
                color[1] = 0xFF;
                color[2] = 0xFF;
            } else {
                color[1] = 0x00;
                color[2] = 0x00;
            }
            if (x == 0 && y == 0) {
                GC9A01_write(color, sizeof(color));
            } else {
                GC9A01_write_continue(color, sizeof(color));
            }
        }
    }

    delay(1000);

}

Looking at your "schematic" you are using the same chip select for both, they must be different, that is the basic premise of SPI.

Hi, thank you very much for trying to help me.

I have only the LCD screen wired on my arduino Nicla. So it's the only device that use the CS Pin N° PE_11.

According to the author if this driver, this code is supposed to be simple for testing a GC9A01 LCD with other board than Arduino uno or Raspberry.

The arduino GFX library seems uncompatible with the mbed core with the arduino nicla vision. So I modified a custom GFX library around the SPI transaction levels.
I openned another post due to crash errors link to SPI transactions but the best answer contain the solution of this post.

i have the same -Display & Nicla Vision

i also tried it with other displays and drivers wich works perfect with Portenta H7 and Breakout Board
ST7789v_arduino.h

probably it's the pin declaraiton ...

did you find a solution ?

No. I didn't find a solution in C but I highly modified a library in micropython from this github depository : https://github.com/russhughes/gc9a01py
And I'm pretty sure of my pin declaration in C, as it works in micropython.

Moreover, it's more convenient for me to use micropython with the nicla vision to record mjpg videos.

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