Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSD1309 on SPI bus (IDFGH-9249) #10635

Closed
3 tasks done
DmytroKoval opened this issue Jan 27, 2023 · 4 comments
Closed
3 tasks done

SSD1309 on SPI bus (IDFGH-9249) #10635

DmytroKoval opened this issue Jan 27, 2023 · 4 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@DmytroKoval
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

esp-idf-v5.0

Operating System used.

Windows

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

PowerShell

Development Kit.

ESP-WROOM32

Power Supply used.

USB

What is the expected behavior?

I tried to use ESP-IDF 5.0 LED driver + LVGL with SSD1309 OLED connected via SPI. As a code base an I2C OLED example for SSD1306 display was taken. SSD1306 and SSD1309 are compatible at command level. I changed I2C bus/io config to SPI. Sample initialization code is shown below.

    ESP_LOGI(TAG, "Initialize SPI bus");
    spi_bus_config_t buscfg = {
        .sclk_io_num = EXAMPLE_PIN_NUM_SCL,
        .mosi_io_num = EXAMPLE_PIN_NUM_SDA,
        .miso_io_num = -1,
        .quadwp_io_num = -1,
        .quadhd_io_num = -1,
        .max_transfer_sz = EXAMPLE_LCD_H_RES * 80 * sizeof(uint16_t),
    };
    ESP_ERROR_CHECK(spi_bus_initialize(LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));


    ESP_LOGI(TAG, "Install panel IO");
    esp_lcd_panel_io_handle_t io_handle = NULL;
    esp_lcd_panel_io_spi_config_t io_config = {
        .dc_gpio_num = EXAMPLE_PIN_NUM_LCD_DC,
        .cs_gpio_num = EXAMPLE_PIN_NUM_LCD_CS,
        .pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
        .lcd_cmd_bits = EXAMPLE_LCD_CMD_BITS,
        .lcd_param_bits = EXAMPLE_LCD_PARAM_BITS,
        .spi_mode = 0,
        .trans_queue_depth = 10,
        .on_color_trans_done = example_notify_lvgl_flush_ready,
        .user_ctx = &disp_drv,
    };
    // Attach the LCD to the SPI bus
    ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_HOST, &io_config, &io_handle));


    ESP_LOGI(TAG, "Install SSD1309 panel driver");
    esp_lcd_panel_handle_t panel_handle = NULL;
    esp_lcd_panel_dev_config_t panel_config = {
        .reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
        .bits_per_pixel = 1,
    };

    ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1306(io_handle, &panel_config, &panel_handle));

    ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
    ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
    ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));

After 3 last lines of code display should have being initialized.

What is the actual behavior?

After 3 last lines of code shown above display is filled with noisy pixels with no other output.

Steps to reproduce.

  1. Connect SSD1309 128x64 monochrome OLED display to ESP32 via 3- or 4-line SPI
  2. Try to initialize it using esp_lcd component
  3. Osberve pixel noise at the display output

Debug Logs.

No response

More Information.

After investigation I found function
static esp_err_t panel_io_spi_tx_param(esp_lcd_panel_io_t *io, int lcd_cmd, const void *param, size_t param_size)
at
components/esp_lcd/src/esp_lcd_panel_io_spi.c
which transmits data/commands via SPI. I noticed, that it inverts D/C line before command parameter transmission (this line). But according to SSD1309 datasheet D/C line should be held at low level (command mode) during transmission of command parameters, and it is stated in both SSD1306 and SSD1309 datasheets.

@DmytroKoval DmytroKoval added the Type: Bug bugs in IDF label Jan 27, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 27, 2023
@github-actions github-actions bot changed the title SSD1309 on SPI bus SSD1309 on SPI bus (IDFGH-9249) Jan 27, 2023
@suda-morris
Copy link
Collaborator

@DmytroKoval Thanks for reporting! Looks like SSD13xx OLED LCD SPI mode is a little different from other LCD screens like ST7789, where the DC level will turn high when transmitting parameters.

We will consider to make that configurable in the esp_lcd_panel_io_spi_config_t structure. e.g. by introducing a new flag dc_high_on_param

@DmytroKoval
Copy link
Author

@DmytroKoval Thanks for reporting! Looks like SSD13xx OLED LCD SPI mode is a little different from other LCD screens like ST7789, where the DC level will turn high when transmitting parameters.
We will consider to make that configurable in the esp_lcd_panel_io_spi_config_t structure. e.g. by introducing a new flag dc_high_on_param

That's smart, because SSD1322 and 1351 (for example, I didn't check all product line) require D/C high on parameter transmission.

Good luck with update!

@kscz
Copy link
Contributor

kscz commented Jan 1, 2024

Any chance this might be resolved before the 5.2 release? I can make the pull request if it would help

kscz added a commit to kscz/esp-idf that referenced this issue Jan 1, 2024
kscz added a commit to kscz/esp-idf that referenced this issue Jan 1, 2024
kscz added a commit to kscz/esp-idf that referenced this issue Jan 1, 2024
kscz added a commit to kscz/esp-idf that referenced this issue Jan 1, 2024
Add in a flag to keep the DC pin in the command state during parameter transfer

fixes esp-idf issue espressif#10635
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jan 2, 2024
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: In Progress Work is in progress labels Jan 2, 2024
@suda-morris
Copy link
Collaborator

Thanks for the contribution. After the PR gets merged to the master branch, we will backport it to release/v5.2 for sure. @kscz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants