SK6812 RGBW LEDs flickering - RMT Driver
Posted: Mon Mar 19, 2018 1:06 pm
Hi,
using the RMT Driver I am trying to generate a signal for the SK6812 RGBW LEDs. My issue is that the LEDs are flickering in the desired color and almost unnoticeable changing colors, rather than staying at the same value. I started by manually programming the timings. The code is attached. Can anyone give me a hint what am I doing wrong? The Waveform looks rather good, but is shifting in time.
Thanks for any help.
TheSub6
PS: Am I right that the RMT DATA MODE is obsolete?
using the RMT Driver I am trying to generate a signal for the SK6812 RGBW LEDs. My issue is that the LEDs are flickering in the desired color and almost unnoticeable changing colors, rather than staying at the same value. I started by manually programming the timings. The code is attached. Can anyone give me a hint what am I doing wrong? The Waveform looks rather good, but is shifting in time.
Thanks for any help.
TheSub6
PS: Am I right that the RMT DATA MODE is obsolete?
Code: Select all
/* RMT transmit example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "driver/rmt.h"
static const char *RMT_TX_TAG = "RMT Tx";
#define RMT_TX_CHANNEL RMT_CHANNEL_0
#define RMT_TX_GPIO 18
rmt_item32_t pixels[] = {
// 8 Bit G
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
//8 Bit R
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
// 8 Bit B
{{{6, 1, 6, 0}}},
{{{6, 1, 6, 0}}},
{{{6, 1, 6, 0}}},
{{{6, 1, 6, 0}}},
{{{6, 1, 6, 0}}},
{{{6, 1, 6, 0}}},
{{{6, 1, 6, 0}}},
{{{6, 1, 6, 0}}},
// 8 Bit W
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{3, 1, 9, 0}}},
{{{0, 0, 800, 0}}},
// RMT end marker
{{{ 0, 0, 0, 0 }}}
};
/*
* Initialize the RMT Tx channel
*/
static void rmt_tx_int()
{
rmt_config_t config;
config.rmt_mode = RMT_MODE_TX;
config.channel = RMT_TX_CHANNEL;
config.gpio_num = RMT_TX_GPIO;
config.mem_block_num = 1;
config.tx_config.loop_en = 0;
config.tx_config.carrier_en = 1;
config.tx_config.idle_output_en = 1;
config.tx_config.idle_level = (rmt_idle_level_t)0;
config.tx_config.carrier_duty_percent = 50;
config.tx_config.carrier_freq_hz = 10000;
config.tx_config.carrier_level = (rmt_carrier_level_t)0;
// set the maximum clock divider to be able to output
// RMT pulses in range of about one hundred nanoseconds
// a divider of 8 will give us 80 MHz / 8 = 10 MHz -> 0.1 us
config.clk_div = 8;
ESP_ERROR_CHECK(rmt_config(&config));
ESP_ERROR_CHECK(rmt_driver_install(config.channel, 0, 0));
}
void app_main(void *ignore)
{
ESP_LOGI(RMT_TX_TAG, "Configuring transmitter");
rmt_tx_int();
int number_of_items = sizeof(pixels) / sizeof(pixels[0]);
while (1) {
ESP_ERROR_CHECK(rmt_write_items(RMT_TX_CHANNEL, pixels, number_of_items, 1));
ESP_LOGI(RMT_TX_TAG, "Transmission complete");
//vTaskDelay(6000 / portTICK_PERIOD_MS);
}
vTaskDelete(NULL);
}