rmt多路同时发送遇到问题
Posted: 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):
输出如下就没有了(卡住了):
将ESP_LOGI修改到循环内部,rmt_transmit函数的上面,输出如下:
但是0、1信道灯亮的情况不符合预期,观察输出左边的时间,后面几个信道的输出符合预期,但是有点像是有了延迟后得到的效果,不可接受。
rmt_transmit函数内加了三处ESP_LOGI后部分输出如下:
程序正常运行,但是实际和下面加了延迟的效果类似,不可接受。
取消最上面代码对延迟的注释,运行输出如下:
程序运行正常,但是加了延迟不可接受。
期望:8个信道能够排队正常发送数据,8个通道操作共计488个灯花费的时间不应明显超过一个通道操作的时间。最好是能并行发,不要求完全同步
结果:发送数据紊乱,或者需要加延迟(测试超过5ms,10ms延迟可用)才能正常亮灯,但时间不满足期望,不如一个通道控制
如下操作也尝试修改过RMT ISR IRAM-Safe,无影响。不知道是哪里的问题,有同时使用多信道控制WS2812B的朋友,欢迎讨论。
程序主要参考examples\peripherals\rmt\led_strip修改而来,核心发送数据的代码如下(LED_NUMBERS=61):
- ESP_LOGI(TAG, "rmt_transmit data.");
- for (int i=0; i<LED_ROWS; i++) {
- ESP_ERROR_CHECK(rmt_transmit(tx_channels[i], led_encoder, led_strip_pixels[i], LED_NUMBERS*sizeof(GRB), &tx_config));
- // vTaskDelay(pdMS_TO_TICKS(10));
- }
- vTaskDelay(pdMS_TO_TICKS(200));
- memset(led_strip_pixels, 0, LED_ROWS*LED_NUMBERS*sizeof(GRB));
- ESP_LOGI(TAG, "rmt_transmit 0.");
- for (int i=0; i<LED_ROWS; i++) {
- ESP_ERROR_CHECK(rmt_transmit(tx_channels[i], led_encoder, led_strip_pixels[i], LED_NUMBERS*sizeof(GRB), &tx_config));
- // vTaskDelay(pdMS_TO_TICKS(10));
- }
- vTaskDelay(pdMS_TO_TICKS(200));
- I (463) EOAL: Install led strip encoder
- I (473) EOAL: Start LED rainbow chase
- I (473) EOAL: rmt_transmit data.
- I (683) EOAL: rmt_transmit 0.
- I (463) EOAL: Install led strip encoder
- I (473) EOAL: Start LED rainbow chase
- I (473) EOAL: rmt_transmit data tx_channels: 0.
- I (483) EOAL: rmt_transmit data tx_channels: 1.
- I (483) EOAL: rmt_transmit data tx_channels: 2.
- I (493) EOAL: rmt_transmit data tx_channels: 3.
- I (493) EOAL: rmt_transmit data tx_channels: 4.
- I (503) EOAL: rmt_transmit data tx_channels: 5.
- I (503) EOAL: rmt_transmit data tx_channels: 6.
- I (513) EOAL: rmt_transmit data tx_channels: 7.
- I (713) EOAL: rmt_transmit 0 tx_channels: 0.
- I (713) EOAL: rmt_transmit 0 tx_channels: 1.
- I (713) EOAL: rmt_transmit 0 tx_channels: 2.
- I (713) EOAL: rmt_transmit 0 tx_channels: 3.
- I (713) EOAL: rmt_transmit 0 tx_channels: 4.
- I (723) EOAL: rmt_transmit 0 tx_channels: 5.
- I (723) EOAL: rmt_transmit 0 tx_channels: 6.
- I (733) EOAL: rmt_transmit 0 tx_channels: 7.
- ...循环输出
rmt_transmit函数内加了三处ESP_LOGI后部分输出如下:
- I (2713) rmt: acquire one transaction description from ready_queue or done_queue
- I (2713) rmt: send the transaction descriptor to queue
- I (2713) rmt: rmt_ll_enable_interrupt
- I (2723) EOAL: rmt_transmit data tx_channels: 1.
- I (2723) rmt: acquire one transaction description from ready_queue or done_queue
- I (2733) rmt: send the transaction descriptor to queue
- I (2743) rmt: rmt_ll_enable_interrupt
- I (2743) EOAL: rmt_transmit data tx_channels: 2.
- I (2753) rmt: acquire one transaction description from ready_queue or done_queue
- I (2753) rmt: send the transaction descriptor to queue
- I (2763) rmt: rmt_ll_enable_interrupt
- I (2763) EOAL: rmt_transmit data tx_channels: 3.
- I (2773) rmt: acquire one transaction description from ready_queue or done_queue
- I (2783) rmt: send the transaction descriptor to queue
- I (2783) rmt: rmt_ll_enable_interrupt
- I (2793) EOAL: rmt_transmit data tx_channels: 4.
- I (2793) rmt: acquire one transaction description from ready_queue or done_queue
- I (2803) rmt: send the transaction descriptor to queue
- I (2813) rmt: rmt_ll_enable_interrupt
- I (2813) EOAL: rmt_transmit data tx_channels: 5.
- I (2823) rmt: acquire one transaction description from ready_queue or done_queue
- I (2833) rmt: send the transaction descriptor to queue
- I (2833) rmt: rmt_ll_enable_interrupt
- I (2843) EOAL: rmt_transmit data tx_channels: 6.
- I (2843) rmt: acquire one transaction description from ready_queue or done_queue
- I (2853) rmt: send the transaction descriptor to queue
- I (2853) rmt: rmt_ll_enable_interrupt
- I (2863) EOAL: rmt_transmit data tx_channels: 7.
- I (2863) rmt: acquire one transaction description from ready_queue or done_queue
- I (2873) rmt: send the transaction descriptor to queue
- I (2883) rmt: rmt_ll_enable_interrupt
- I (3083) EOAL: rmt_transmit 0 tx_channels: 0.
取消最上面代码对延迟的注释,运行输出如下:
- I (463) EOAL: Install led strip encoder
- I (473) EOAL: Start LED rainbow chase
- I (473) EOAL: rmt_transmit data.
- I (763) EOAL: rmt_transmit 0.
- ...循环输出