ESP32-WROOM-32E RMT Usage
Posted: Wed Sep 24, 2025 4:07 am
Hi
I am trying to use RMT to generate signal.
Below is my code:
void RMT1 () {
rmt_channel_handle_t tx_channels[2] = {NULL};
int tx_gpio_number[2] = {4, 4};
rmt_copy_encoder_config_t copy_config = {};
rmt_encoder_handle_t copy_encoder = NULL;
ESP_ERROR_CHECK(rmt_new_copy_encoder(©_config, ©_encoder));
for (int i = 0; i < 1; i++) {
rmt_tx_channel_config_t tx_chan_config = {
.clk_src = RMT_CLK_SRC_DEFAULT,
.gpio_num = tx_gpio_number,
.mem_block_symbols = 64,
.resolution_hz = 1 * 1000 * 1000,
.trans_queue_depth = 1,
};
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &tx_channels));
}
for (int i = 0; i < 1; i++) {
ESP_ERROR_CHECK(rmt_enable(tx_channels));
}
rmt_symbol_word_t your_raw_rmt_symbols[] = {
{.duration0 = 1, .level0 = 1, .duration1 = 1, .level1 = 0},
// ... more symbols
};
rmt_symbol_word_t items[10];
for (int i = 0; i < 10; i++) {
items.level0 = 1;
items.duration0 = 1;
items.level1 = 0;
items.duration1 = 1;
}
rmt_transmit_config_t tx_config ={};
ESP_ERROR_CHECK(rmt_transmit(tx_channels[0], copy_encoder, items , sizeof (items), &tx_config));
}
I expect to have signal high for 1us , low for 1us and repeat 10 times.
But what i got is as below:
I am using ESP-IDF v5.3.1
Please help me with this.
Thanks a lots.
I am trying to use RMT to generate signal.
Below is my code:
void RMT1 () {
rmt_channel_handle_t tx_channels[2] = {NULL};
int tx_gpio_number[2] = {4, 4};
rmt_copy_encoder_config_t copy_config = {};
rmt_encoder_handle_t copy_encoder = NULL;
ESP_ERROR_CHECK(rmt_new_copy_encoder(©_config, ©_encoder));
for (int i = 0; i < 1; i++) {
rmt_tx_channel_config_t tx_chan_config = {
.clk_src = RMT_CLK_SRC_DEFAULT,
.gpio_num = tx_gpio_number,
.mem_block_symbols = 64,
.resolution_hz = 1 * 1000 * 1000,
.trans_queue_depth = 1,
};
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &tx_channels));
}
for (int i = 0; i < 1; i++) {
ESP_ERROR_CHECK(rmt_enable(tx_channels));
}
rmt_symbol_word_t your_raw_rmt_symbols[] = {
{.duration0 = 1, .level0 = 1, .duration1 = 1, .level1 = 0},
// ... more symbols
};
rmt_symbol_word_t items[10];
for (int i = 0; i < 10; i++) {
items.level0 = 1;
items.duration0 = 1;
items.level1 = 0;
items.duration1 = 1;
}
rmt_transmit_config_t tx_config ={};
ESP_ERROR_CHECK(rmt_transmit(tx_channels[0], copy_encoder, items , sizeof (items), &tx_config));
}
I expect to have signal high for 1us , low for 1us and repeat 10 times.
But what i got is as below:
I am using ESP-IDF v5.3.1
Please help me with this.
Thanks a lots.