Code: Select all
[///esp32s3在使用RMT多通道发送时总有一个通道比别的通道慢20ns
//代码如下]
//esp32s3在使用RMT多通道发送时总有一个通道比别的通道慢20ns
//代码如下
rmt_config_t config1;
config1.channel = RMT_CHANNEL_0;
config1.clk_div = 4;
config1.gpio_num = GPIO_NUM_40;
config1.mem_block_num = 1;
config1.rmt_mode = RMT_MODE_TX;
config1.tx_config.carrier_en = false;
config1.tx_config.idle_output_en = true; // 空闲输出打开
config1.tx_config.idle_level = RMT_IDLE_LEVEL_LOW; // 空闲时候为低电平
config1.tx_config.loop_en = false; // 关闭持续发送
rmt_config_t config2 ;
config2.channel = RMT_CHANNEL_1;
config2.clk_div = 4;
config2.gpio_num = GPIO_NUM_39;
config2.mem_block_num = 1;
config2.rmt_mode = RMT_MODE_TX;
config2.tx_config.carrier_en = false;
config2.tx_config.idle_output_en = true; // 空闲输出打开
config2.tx_config.idle_level = RMT_IDLE_LEVEL_LOW; // 空闲时候为低电平
config2.tx_config.loop_en = false; // 关闭持续发送
rmt_config_t config3;
config3.channel = RMT_CHANNEL_2;
config3.clk_div = 4;
config3.gpio_num = GPIO_NUM_38;
config3.mem_block_num = 1;
config3.rmt_mode = RMT_MODE_TX;
config3.tx_config.carrier_en = false;
config3.tx_config.idle_output_en = true; // 空闲输出打开
config3.tx_config.idle_level = RMT_IDLE_LEVEL_LOW; // 空闲时候为低电平
config3.tx_config.loop_en = false;
rmt_config_t config4;
config4.channel = RMT_CHANNEL_3;
config4.clk_div = 4;
config4.gpio_num = GPIO_NUM_37;
config4.mem_block_num = 1;
config4.rmt_mode = RMT_MODE_TX;
config4.tx_config.carrier_en = false;
config4.tx_config.idle_output_en = true; // 空闲输出打开
config4.tx_config.idle_level = RMT_IDLE_LEVEL_LOW; // 空闲时候为低电平
config4.tx_config.loop_en = false;
rmt_config(&config1);
rmt_config(&config2);
rmt_config(&config3);
rmt_config(&config4);
rmt_driver_install(config1.channel, 0, 0);
rmt_driver_install(config2.channel, 0, 0);
rmt_driver_install(config3.channel, 0, 0);
rmt_driver_install(config4.channel, 0, 0);
rmt_add_channel_to_group(RMT_CHANNEL_0);
rmt_add_channel_to_group(RMT_CHANNEL_1);
rmt_add_channel_to_group(RMT_CHANNEL_2);
rmt_add_channel_to_group(RMT_CHANNEL_3);
static const rmt_item32_t morse_esp[] = {
{{{1, 1, 1, 0}}},
{{{1, 1, 1, 0}}},
{{{1, 1, 1, 0}}},
{{{1, 1, 1, 0}}},
{{{2, 1, 2, 0}}},
{{{2, 1, 2, 0}}},
{{{2, 1, 2, 0}}},
{{{2, 1, 2, 0}}},
{{{2, 1, 2, 0}}},
{{{2, 1, 2, 0}}},
{{{2, 1, 2, 0}}},
{{{2, 1, 2, 0}}},
{{{0, 0, 0, 0}}}};
while (1)
{
ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_0, morse_esp,sizeof(morse_esp) / sizeof(morse_esp[0]), false));
ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_1, morse_esp,sizeof(morse_esp) / sizeof(morse_esp[0]), false));
ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_2, morse_esp,sizeof(morse_esp) / sizeof(morse_esp[0]), false));
ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_3, morse_esp,sizeof(morse_esp) / sizeof(morse_esp[0]), false));
vTaskDelay(1000 / portTICK_PERIOD_MS);
}