ESP32 rmt_tx sync manager minimal example
See ESP32 rmt_tx simple pulse example (ESP-IDF) for an example without sync manager
#include <driver/rmt_tx.h>
rmt_channel_handle_t channel;
rmt_tx_channel_config_t tx_chan_config = {
.gpio_num = GPIO_NUM_19, // GPIO number
.clk_src = RMT_CLK_SRC_DEFAULT, // select source clock
.resolution_hz = 1 * 1000 * 1000, // 1 MHz resolution
.mem_block_symbols = 64, // memory block size, 64 * 4 = 256 Bytes
.trans_queue_depth = 1, // set the number of transactions that can pend in the background
};
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &channel));
ESP_ERROR_CHECK(rmt_enable(channel));
rmt_symbol_word_t txdata[64];
txdata[0] = {
.duration0 = 100,
.level0 = 1,
.duration1 = 0,
.level1 = 0,
};
// install sync manager
rmt_channel_handle_t tx_channels[] = {channel};
rmt_sync_manager_handle_t synchro = NULL;
rmt_sync_manager_config_t synchro_config = {
.tx_channel_array = tx_channels,
.array_size = sizeof(tx_channels) / sizeof(rmt_channel_handle_t),
};
ESP_ERROR_CHECK(rmt_new_sync_manager(&synchro_config, &synchro));
// Create simple encoder
rmt_copy_encoder_config_t encoder_config;
rmt_encoder_handle_t encoder;
ESP_ERROR_CHECK(rmt_new_copy_encoder(&encoder_config, &encoder));
rmt_transmit_config_t tx_config = {
.loop_count = 0, // no transfer loop
};
while(true)
{
ESP_ERROR_CHECK(rmt_transmit(channel, encoder, pulseRMT, 1*sizeof(rmt_symbol_word_t), &tx_config));
// Wait for one second
vTaskDelay(10 / portTICK_PERIOD_MS);
}