I am trying to use the RMT peripheral of the ESP32 with a very simple example to send a signal-sequence in infinite loop.
If I use rmt_write_items() to activate the RMT peripheral everything works fine.
But I need to change the signal-sequence at run-time. According to the ESP32 RMT documentation, rmt_fill_tx_items() should be used to change the signal-sequence at runtime. But once I use rmt_fill_tx_items() (instead of rmt_write_items()), the RMT peripheral does not work anymore and sends just random stuff.
Here is my code:
Code: Select all
#include <Arduino.h>
#include "driver/rmt.h"
rmt_config_t config;
rmt_item32_t items[1];
void setup()
{
Serial.begin(115200);
config.rmt_mode = RMT_MODE_TX;
config.channel = RMT_CHANNEL_0;
config.gpio_num = GPIO_NUM_4;
config.mem_block_num = 1;
config.tx_config.loop_en = 1;
config.tx_config.carrier_en = 0;
config.tx_config.idle_output_en = 1;
config.tx_config.idle_level = RMT_IDLE_LEVEL_LOW;
config.tx_config.carrier_level = RMT_CARRIER_LEVEL_HIGH;
config.clk_div = 80; // 80MHx / 80 = 1MHz 0r 1uS per count
ESP_ERROR_CHECK(rmt_config(&config));
ESP_ERROR_CHECK(rmt_driver_install(config.channel, 0, 0));
items[0].duration0 = 3;
items[0].level0 = 1;
items[0].duration1 = 10;
items[0].level1 = 0;
items[1].duration0 = 5;
items[1].level0 = 1;
items[1].duration1 = 5;
items[1].level1 = 0;
ESP_ERROR_CHECK(rmt_fill_tx_items(config.channel, items, 2, 0));
ESP_ERROR_CHECK(rmt_tx_start(config.channel, false));
}
void loop()
{
}
Thank you very much!