Skip to content

Instantly share code, notes, and snippets.

@nickzoic
Created January 24, 2020 00:52
Show Gist options
  • Select an option

  • Save nickzoic/f552a4933e147481f9bafd63b4c245be to your computer and use it in GitHub Desktop.

Select an option

Save nickzoic/f552a4933e147481f9bafd63b4c245be to your computer and use it in GitHub Desktop.
Problem with ESP32 RMT
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "driver/rmt.h"
static const char *TAG = "test";
rmt_item32_t items[] = {
{{{ 50, 0, 50, 0 }}},
{{{ 2, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
{{{ 1, 1, 1, 0 }}},
};
void app_main(void *ignore)
{
rmt_config_t config;
config.rmt_mode = RMT_MODE_TX;
config.channel = RMT_CHANNEL_0;
config.gpio_num = 12;
config.mem_block_num = 1;
config.tx_config.carrier_en = 0;
config.tx_config.loop_en = 1;
config.tx_config.idle_output_en = 1;
config.tx_config.idle_level = 0;
config.clk_div = 10;
ESP_LOGI(TAG, "rmt_config");
ESP_ERROR_CHECK(rmt_config(&config));
ESP_LOGI(TAG, "rmt_driver_install");
ESP_ERROR_CHECK(rmt_driver_install(config.channel, 0, 0));
int number_of_items = sizeof(items) / sizeof(rmt_item32_t);
ESP_LOGI(TAG, "rmt_write_items");
ESP_ERROR_CHECK(rmt_write_items(RMT_CHANNEL_0, items, number_of_items, false));
while (1) {
ESP_LOGI(TAG, "Waiting");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment