Sharp Memory display via SPI from Arduino Nano RP2040 C++

Update:
Maybe someone will find it useful:
I solved the issue and created a custom driver for interfacing Sharp Memory LCD displays with the RP2040 using the Pico SDK, specifically designed to maximize performance and minimize power consumption. The driver can be found here:


I have an Adafruit Sharp Memory display connected via SPI to Arduino Nano RP2040 Connect. I don't use Arduino IDE nor Arduino libraries. I write the code in C++ like I would write for RP2040 on Pi Pico, so I'm using Pico/RP2040 libraries. I'm building it and then just copying the .uf2 file to Arduino.

I'm trying to control the display but without success and I have no idea what I'm doing wrong. Here is my code, where I'm sending a command which should clear the display but it does not:

#include <stdio.h>
#include <stdlib.h>
#include "pico/stdlib.h"
#include "hardware/spi.h"
#include "hardware/gpio.h"

// ---SPI
// Pins for Arduino
#define SCK_PIN  13     // SCLK / SCK
#define MOSI_PIN 11     // MOSI / COPI
#define SS_PIN   10     // SS / CS

// ---Sharp display
#define WIDTH 144
#define HEIGHT 168


int main() {

    stdio_init_all();
    printf("START \n");

    bool vcom_bool_{false};

    spi_init(spi0, 2000000);
    spi_set_format( spi0, 8, SPI_CPOL_0, SPI_CPHA_0, SPI_MSB_FIRST);
    gpio_set_function(MOSI_PIN, GPIO_FUNC_SPI);
    gpio_set_function(SCK_PIN, GPIO_FUNC_SPI);

    gpio_init(SS_PIN);
    gpio_set_dir(SS_PIN, GPIO_OUT);
    gpio_put(SS_PIN, 0);  // this display is low on inactive


    while(true)
    {
        printf("VCOM = %b \n", vcom_bool_);

        gpio_put(SS_PIN, 1);

        // Clear the display
        uint8_t buf[2];
        if(vcom_bool_)
        {
            buf[0] = 0b01100000;
            vcom_bool_ = false;
        }
        else
        {
            buf[0] = 0b00100000;
            vcom_bool_ = true;
        }
        buf[1] = 0b00000000;
        spi_write_blocking(spi0, buf, 2);

        gpio_put(SS_PIN, 0);
        sleep_ms(10);
        

        sleep_ms(500);
    }
}

Display and wiring are ok, because when I run example code from Adafruit (it is using Arduino's libraries) it works.

I follow this documentation from Sharp: https://www.sharpsde.com/fileadmin/products/Displays/2016_SDE_App_Note_for_Memory_LCD_programming_V1.3.pdf

I also reviewed the code from Adafruit and the SPI communication seems to be done in the same way.

What am I doing wrong? Is there some issue with using Pico libraries for Arduino Nano RP2040? I did I2C communication in the same way (Pico/RP2040 libraries, .uf2 copied to Arduino Nano RP2040) and it worked.

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