Can I use DMA for ESP32C3`IIC to drive ssd1306?

XH_Timmo
Posts: 5
Joined: Thu Jul 25, 2024 1:44 pm

Can I use DMA for ESP32C3`IIC to drive ssd1306?

Postby XH_Timmo » Sat Aug 17, 2024 9:07 am

It has afterimage when I using ESP32C3`IIC to drive ssd1306 with 1 MHz. So I want to solve this problen with DMA. But in Technical Manuals, I can`t find IIC config in DMA, like this:
屏幕截图 2024-08-17 170549.png
屏幕截图 2024-08-17 170549.png (33.94 KiB) Viewed 1919 times
This is my code to write data:
  1. static esp_err_t ssd1306_write_data(void *sensor, const uint8_t *const data_buf,
  2.                                     const uint8_t data_len) {
  3.   ssd1306_dev_t *sens = (ssd1306_dev_t *)sensor;
  4.   esp_err_t ret;
  5.  
  6.   i2c_cmd_handle_t cmd = i2c_cmd_link_create();
  7.   ret = i2c_master_start(cmd);
  8.   assert(ESP_OK == ret);
  9.   ret = i2c_master_write_byte(cmd, sens->dev_addr | I2C_MASTER_WRITE, true);
  10.   assert(ESP_OK == ret);
  11.   ret = i2c_master_write_byte(cmd, 0x40, true);
  12.   assert(ESP_OK == ret);
  13.   ret = i2c_master_write(cmd, data_buf, data_len, true);
  14.   assert(ESP_OK == ret);
  15.   ret = i2c_master_stop(cmd);
  16.   assert(ESP_OK == ret);
  17.   ret = i2c_master_cmd_begin(sens->bus, cmd, 1000 / portTICK_PERIOD_MS);
  18.   i2c_cmd_link_delete(cmd);
  19.  
  20.   return ret;
  21. }
This is my code to init ssd1306:
  1. void SSD1306_init(void) {
  2.  
  3.   esp_err_t ret;
  4.  
  5.   ssd1306 = ssd1306_create(I2C_MASTER_NUM, SSD1306_ADDR);
  6.   TEST_ASSERT_NOT_NULL_MESSAGE(ssd1306, "SSD1306 create returned NULL");
  7.   ssd1306_write_cmd(ssd1306, 0xAE);
  8.   ssd1306_write_cmd(ssd1306, 0x00);
  9.   ssd1306_write_cmd(ssd1306, 0x10);
  10.   ssd1306_write_cmd(ssd1306, 0x40);
  11.   ssd1306_write_cmd(ssd1306, 0xB0);
  12.   ssd1306_write_cmd(ssd1306, 0x81);
  13.   ssd1306_write_cmd(ssd1306, 0xFF);
  14.   ssd1306_write_cmd(ssd1306, 0xA1);
  15.   ssd1306_write_cmd(ssd1306, 0xA6);
  16.   ssd1306_write_cmd(ssd1306, 0xA8);
  17.   ssd1306_write_cmd(ssd1306, 0x3F);
  18.   ssd1306_write_cmd(ssd1306, 0xC8);
  19.   ssd1306_write_cmd(ssd1306, 0xD3);
  20.   ssd1306_write_cmd(ssd1306, 0x00);
  21.   ssd1306_write_cmd(ssd1306, 0xD5);
  22.   ssd1306_write_cmd(ssd1306, 0x80);
  23.   ssd1306_write_cmd(ssd1306, 0xD8);
  24.   ssd1306_write_cmd(ssd1306, 0x05);
  25.   ssd1306_write_cmd(ssd1306, 0xD9);
  26.   ssd1306_write_cmd(ssd1306, 0xF1);
  27.   ssd1306_write_cmd(ssd1306, 0xDA);
  28.   ssd1306_write_cmd(ssd1306, 0x12);
  29.   ssd1306_write_cmd(ssd1306, 0xDB);
  30.   ssd1306_write_cmd(ssd1306, 0x30);
  31.   ssd1306_write_cmd(ssd1306, 0x8D);
  32.   ssd1306_write_cmd(ssd1306, 0x14);
  33.   ssd1306_write_cmd(ssd1306, 0xAF);
  34.  
  35.   ssd1306_clean();
  36.   ESP_LOGI(TAG, "Finish init %s", TAG);
  37. }

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

Re: Can I use DMA for ESP32C3`IIC to drive ssd1306?

Postby ESP_Sprite » Sat Aug 17, 2024 10:22 am

No, I2C doesn't support DMA. Note that this generally also is not needed as the I2C protocol itself is not really that fast. If your display supports it, you can try using SPI; that can go faster and does support DMA.

XH_Timmo
Posts: 5
Joined: Thu Jul 25, 2024 1:44 pm

Re: Can I use DMA for ESP32C3`IIC to drive ssd1306?

Postby XH_Timmo » Sat Aug 17, 2024 11:36 am

Thank you. I will look for a better displayer.

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Can I use DMA for ESP32C3`IIC to drive ssd1306?

Postby MicroController » Sat Aug 17, 2024 6:41 pm

XH_Timmo wrote:
Sat Aug 17, 2024 9:07 am
It has afterimage
What does that mean?
So I want to solve this problem with DMA.
How would using DMA solve your problem?

XH_Timmo
Posts: 5
Joined: Thu Jul 25, 2024 1:44 pm

Re: Can I use DMA for ESP32C3`IIC to drive ssd1306?

Postby XH_Timmo » Sat Sep 14, 2024 8:02 am

MicroController wrote: What does that mean?
Sorry, my English is bad , I meanings “残影” , looks like flash frequence is not enough.
MicroController wrote: How would using DMA solve your problem?
If I can use DMA, my transmission will be faster than now.

QQ26750452
Posts: 17
Joined: Thu May 13, 2021 1:48 pm

Re: Can I use DMA for ESP32C3`IIC to drive ssd1306?

Postby QQ26750452 » Sat Sep 14, 2024 1:17 pm

这是一个悲催的现实!国语分论坛一年半载没人回复,只能用蹩脚的英语硬着头皮混在英文分区里提问!

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Can I use DMA for ESP32C3`IIC to drive ssd1306?

Postby MicroController » Mon Sep 16, 2024 1:29 pm

XH_Timmo wrote:
Sat Sep 14, 2024 8:02 am
If I can use DMA, my transmission will be faster than now.
No, it would not.
I'm not sure what the problem is you're seeing, but it may be more of a timing issue, i.e. synchronization with the display's refresh cycle.
How many pixels at what framerate do you want to draw?

Who is online

Users browsing this forum: Baidu [Spider], Gaston1980 and 162 guests