i could use a helping hand with RMT.
I want to generate a waveform with 194 steps using 4 blocks of the RMT internal memory.
Everything works fine with 64 steps or less, but adding additional steps produces invalid waveforms.
The SDK does not return any errors though.
I created a minimum "not working example" with a clock output that reproduces the problem.
Results and source below. What am i doing wrong here?
Waveform with <= 64 steps (OK) Waveform with > 64 steps (nOK) Waveform with > 64 steps, zoomed out (wtf?!) Sourcecode
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "driver/rmt.h"
- #include "esp_log.h"
- #define TAG "TEST"
- static rmt_config_t const g_rmt_out_config =
- {
- .rmt_mode = RMT_MODE_TX,
- .channel = RMT_CHANNEL_0,
- .gpio_num = GPIO_NUM_14,
- .clk_div = 1,
- .mem_block_num = 4,
- .tx_config =
- {
- .carrier_freq_hz = 1000,
- .carrier_level = RMT_CARRIER_LEVEL_LOW,
- .idle_level = RMT_IDLE_LEVEL_LOW,
- .carrier_duty_percent = 50,
- .carrier_en = false,
- .loop_en = false,
- .idle_output_en = true,
- }
- };
- static rmt_item32_t const gp_rtm_out_item[] =
- {
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 20, .level0 = 0, .duration1 = 20, .level1 = 1 },
- { .duration0 = 0, .level0 = 0, .duration1 = 0, .level1 = 1 }, //stop
- };
- static uint16_t const g_rtm_out_item_size = sizeof(gp_rtm_out_item) / sizeof(rmt_item32_t);
- void app_main(void)
- {
- ESP_LOGE(TAG, "start");
- if(ESP_OK != rmt_config(&g_rmt_out_config))
- {
- ESP_LOGE(TAG, "rmt_config failed");
- }
- if(ESP_OK != rmt_driver_install(g_rmt_out_config.channel, 0, 0))
- {
- ESP_LOGE(TAG, "rmt_driver_install failed");
- }
- if(ESP_OK != rmt_fill_tx_items(g_rmt_out_config.channel, gp_rtm_out_item, g_rtm_out_item_size, 0))
- {
- ESP_LOGE(TAG, "rmt_fill_tx_items failed");
- }
- while (true)
- {
- rmt_tx_start(RMT_CHANNEL_0, true);
- vTaskDelay(1000 / portTICK_PERIOD_MS);
- }
- }
A similar looking problem occures when i remove the stop line. I took that one from the examples. Why do i need that?
- { .duration0 = 0, .level0 = 0, .duration1 = 0, .level1 = 1 }, //stop
Any help or ideas are welcome, because im stuck
My Setup:
Hardware: ESP32-D0WD-V3 custom board with ISSI flash memory
SDK: ESP-IDF v4.1