Page 1 of 1

HELP with strange SPI issue

Posted: Sun Sep 30, 2018 7:28 pm
by wperw1
Hi to all, I'm new to the forum and I'm working on ESP32 for around one year.
In this days I started to work with the 2.9" EPaper Display (EPD) from Waveshare https://www.waveshare.com/wiki/2.9inch_ ... Module_(B), it's an interesting SPI Screen with 3 color (Black White and Red) after some Googling for a decent library for this 3 color EPD (I've find only the lobo library https://github.com/loboris/ESP32_ePaper_example but it isn't compatible with this EPD) I've ended up with writing my own library and publish it on GitHub.

After the headache with documentation of the EPD and the understanding of ESP32 SPI implementation on the Idf 3.1 I've 'mplemented all the code, but the CS PIN not work correctly it's working inverted (I know i can bypass the issue but this is a very strange thing).

So the problem is the CS PIN on ESP work inverted in every configuration it goes UP on SPI transmission.
My configuration is a DevKitC with these PINs configuration
EPD busy ---> GPIO_NUM_4
EPD reset -->GPIO_NUM_16
EPD DC ----->GPIO_NUM_17
EPD CS ----->GPIO_NUM_5
EPD MISO -->GPIO_NUM_23
EPD SCK --->GPIO_NUM_18

The complete code is on GitHub https://github.com/wperw/ESP32_SPIEPDLibrary
And yes comments for now are in italian (I'm italian too)

Attached the pulseview capture image, the capture file couldn't attached

Thank you so much for the help

-wperw

Re: HELP with strange SPI issue

Posted: Wed Oct 03, 2018 5:56 am
by ESP_Sprite
That's a strange thing... I see you're using the polling transmit function, does it also does that if you use the 'normal' SPI transmit function?

Re: HELP with strange SPI issue

Posted: Wed Oct 03, 2018 11:41 am
by wperw1
ESP_Sprite wrote:That's a strange thing... I see you're using the polling transmit function, does it also does that if you use the 'normal' SPI transmit function?
Thanks for the fast response, I don't know, I'll try in this week to change from polling to interrupt.
After the test I'll post the results.

Re: HELP with strange SPI issue

Posted: Thu Oct 25, 2018 9:27 pm
by wperw1
After a lot of time and hours at work I was able to find the time for modify the code as suggested.
The function object of the modify is the SPI_Writethat i report below

Old function:

Code: Select all

void IRAM_ATTR SPI_Write(uint8_t value, EPDDriverParams_t *driver)
{
    esp_err_t ret;

    spi_device_handle_t disp_spi = (spi_device_handle_t)driver->handle;
    spi_transaction_t valueToSend = 
    {
        .flags = SPI_TRANS_USE_TXDATA,
        .cmd = 0,
        .addr = 0,
        .length = 8,
        .rxlength = 0,
        .user = NULL,
        .tx_data = {value}
    };
    //ret = spi_device_transmit(disp_spi, &valueToSend);
    if(ret != ESP_OK) printf("Fail to send SPI data to device with error %d\r\n", ret);
}
New Function:

Code: Select all

void IRAM_ATTR SPI_Write(uint8_t value, EPDDriverParams_t *driver)
{
    esp_err_t ret;

    spi_device_handle_t disp_spi = (spi_device_handle_t)driver->handle;
    spi_transaction_t valueToSend = 
    {
        .flags = SPI_TRANS_USE_TXDATA,
        .cmd = 0,
        .addr = 0,
        .length = 8,
        .rxlength = 0,
        .user = NULL,
        .tx_data = {value}
    };
    //----START MODIFIED PART----//
    ret = spi_device_queue_trans(disp_spi, &valueToSend, portMAX_DELAY);
    if(ret != ESP_OK) printf("Fail to send SPI data to device with error %d\r\n", ret);
    ret = spi_device_get_trans_result(disp_spi, &valueToSend, portMAX_DELAY);
    if(ret != ESP_OK) printf("Fail to send SPI data to device with error %d\r\n", ret);
    //----END MODIFIED PART----//
}
After the modify the problem wasn't change

Re: HELP with strange SPI issue

Posted: Sun Dec 30, 2018 9:10 pm
by wperw1
Problem persist, but I haven't find a solition. Can anyone help me?