rmt多路同时发送遇到问题

Moderator: ESP_Bob

kevinshq
Posts: 1
Joined: Tue Apr 18, 2023 2:22 pm

rmt多路同时发送遇到问题

Postby kevinshq » Tue Apr 18, 2023 2:46 pm

已知:ESP32的RMT不支持sync manager
期望:8个信道能够排队正常发送数据,8个通道操作共计488个灯花费的时间不应明显超过一个通道操作的时间。最好是能并行发,不要求完全同步
结果:发送数据紊乱,或者需要加延迟(测试超过5ms,10ms延迟可用)才能正常亮灯,但时间不满足期望,不如一个通道控制

如下操作也尝试修改过RMT ISR IRAM-Safe,无影响。不知道是哪里的问题,有同时使用多信道控制WS2812B的朋友,欢迎讨论。

程序主要参考examples\peripherals\rmt\led_strip修改而来,核心发送数据的代码如下(LED_NUMBERS=61):
  1.         ESP_LOGI(TAG, "rmt_transmit data.");
  2.         for (int i=0; i<LED_ROWS; i++) {
  3.             ESP_ERROR_CHECK(rmt_transmit(tx_channels[i], led_encoder, led_strip_pixels[i], LED_NUMBERS*sizeof(GRB), &tx_config));
  4.             // vTaskDelay(pdMS_TO_TICKS(10));
  5.         }
  6.         vTaskDelay(pdMS_TO_TICKS(200));
  7.         memset(led_strip_pixels, 0, LED_ROWS*LED_NUMBERS*sizeof(GRB));
  8.         ESP_LOGI(TAG, "rmt_transmit 0.");
  9.         for (int i=0; i<LED_ROWS; i++) {
  10.             ESP_ERROR_CHECK(rmt_transmit(tx_channels[i], led_encoder, led_strip_pixels[i], LED_NUMBERS*sizeof(GRB), &tx_config));
  11.             // vTaskDelay(pdMS_TO_TICKS(10));
  12.         }
  13.         vTaskDelay(pdMS_TO_TICKS(200));
输出如下就没有了(卡住了):
  1. I (463) EOAL: Install led strip encoder
  2. I (473) EOAL: Start LED rainbow chase
  3. I (473) EOAL: rmt_transmit data.
  4. I (683) EOAL: rmt_transmit 0.
将ESP_LOGI修改到循环内部,rmt_transmit函数的上面,输出如下:
  1. I (463) EOAL: Install led strip encoder
  2. I (473) EOAL: Start LED rainbow chase
  3. I (473) EOAL: rmt_transmit data tx_channels: 0.
  4. I (483) EOAL: rmt_transmit data tx_channels: 1.
  5. I (483) EOAL: rmt_transmit data tx_channels: 2.
  6. I (493) EOAL: rmt_transmit data tx_channels: 3.
  7. I (493) EOAL: rmt_transmit data tx_channels: 4.
  8. I (503) EOAL: rmt_transmit data tx_channels: 5.
  9. I (503) EOAL: rmt_transmit data tx_channels: 6.
  10. I (513) EOAL: rmt_transmit data tx_channels: 7.
  11. I (713) EOAL: rmt_transmit 0 tx_channels: 0.
  12. I (713) EOAL: rmt_transmit 0 tx_channels: 1.
  13. I (713) EOAL: rmt_transmit 0 tx_channels: 2.
  14. I (713) EOAL: rmt_transmit 0 tx_channels: 3.
  15. I (713) EOAL: rmt_transmit 0 tx_channels: 4.
  16. I (723) EOAL: rmt_transmit 0 tx_channels: 5.
  17. I (723) EOAL: rmt_transmit 0 tx_channels: 6.
  18. I (733) EOAL: rmt_transmit 0 tx_channels: 7.
  19. ...循环输出
但是0、1信道灯亮的情况不符合预期,观察输出左边的时间,后面几个信道的输出符合预期,但是有点像是有了延迟后得到的效果,不可接受。
rmt_transmit函数内加了三处ESP_LOGI后部分输出如下:
  1. I (2713) rmt: acquire one transaction description from ready_queue or done_queue
  2. I (2713) rmt: send the transaction descriptor to queue
  3. I (2713) rmt: rmt_ll_enable_interrupt
  4. I (2723) EOAL: rmt_transmit data tx_channels: 1.
  5. I (2723) rmt: acquire one transaction description from ready_queue or done_queue
  6. I (2733) rmt: send the transaction descriptor to queue
  7. I (2743) rmt: rmt_ll_enable_interrupt
  8. I (2743) EOAL: rmt_transmit data tx_channels: 2.
  9. I (2753) rmt: acquire one transaction description from ready_queue or done_queue
  10. I (2753) rmt: send the transaction descriptor to queue
  11. I (2763) rmt: rmt_ll_enable_interrupt
  12. I (2763) EOAL: rmt_transmit data tx_channels: 3.
  13. I (2773) rmt: acquire one transaction description from ready_queue or done_queue
  14. I (2783) rmt: send the transaction descriptor to queue
  15. I (2783) rmt: rmt_ll_enable_interrupt
  16. I (2793) EOAL: rmt_transmit data tx_channels: 4.
  17. I (2793) rmt: acquire one transaction description from ready_queue or done_queue
  18. I (2803) rmt: send the transaction descriptor to queue
  19. I (2813) rmt: rmt_ll_enable_interrupt
  20. I (2813) EOAL: rmt_transmit data tx_channels: 5.
  21. I (2823) rmt: acquire one transaction description from ready_queue or done_queue
  22. I (2833) rmt: send the transaction descriptor to queue
  23. I (2833) rmt: rmt_ll_enable_interrupt
  24. I (2843) EOAL: rmt_transmit data tx_channels: 6.
  25. I (2843) rmt: acquire one transaction description from ready_queue or done_queue
  26. I (2853) rmt: send the transaction descriptor to queue
  27. I (2853) rmt: rmt_ll_enable_interrupt
  28. I (2863) EOAL: rmt_transmit data tx_channels: 7.
  29. I (2863) rmt: acquire one transaction description from ready_queue or done_queue
  30. I (2873) rmt: send the transaction descriptor to queue
  31. I (2883) rmt: rmt_ll_enable_interrupt
  32. I (3083) EOAL: rmt_transmit 0 tx_channels: 0.
程序正常运行,但是实际和下面加了延迟的效果类似,不可接受。
取消最上面代码对延迟的注释,运行输出如下:
  1. I (463) EOAL: Install led strip encoder
  2. I (473) EOAL: Start LED rainbow chase
  3. I (473) EOAL: rmt_transmit data.
  4. I (763) EOAL: rmt_transmit 0.
  5. ...循环输出
程序运行正常,但是加了延迟不可接受。

ESP_Eavo
Posts: 186
Joined: Tue Jun 08, 2021 6:23 am

Re: rmt多路同时发送遇到问题

Postby ESP_Eavo » Tue May 09, 2023 8:40 am

ESP32 不支持同步发送。硬件不支持的,软件没法保证模拟做到同步。

Who is online

Users browsing this forum: No registered users and 6 guests