HELP with strange SPI issue

wperw1
Posts: 6
Joined: Sun Sep 30, 2018 6:50 pm

HELP with strange SPI issue

Postby wperw1 » Sun Sep 30, 2018 7:28 pm

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
Attachments
second.PNG
second.PNG (31.86 KiB) Viewed 6375 times
first.PNG
first.PNG (25.25 KiB) Viewed 6375 times

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: HELP with strange SPI issue

Postby ESP_Sprite » Wed Oct 03, 2018 5:56 am

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?

wperw1
Posts: 6
Joined: Sun Sep 30, 2018 6:50 pm

Re: HELP with strange SPI issue

Postby wperw1 » Wed Oct 03, 2018 11:41 am

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.

wperw1
Posts: 6
Joined: Sun Sep 30, 2018 6:50 pm

Re: HELP with strange SPI issue

Postby wperw1 » Thu Oct 25, 2018 9:27 pm

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
Attachments
after_Interrupt.PNG
after_Interrupt.PNG (18.82 KiB) Viewed 6287 times

wperw1
Posts: 6
Joined: Sun Sep 30, 2018 6:50 pm

Re: HELP with strange SPI issue

Postby wperw1 » Sun Dec 30, 2018 9:10 pm

Problem persist, but I haven't find a solition. Can anyone help me?

Who is online

Users browsing this forum: No registered users and 155 guests