Help in RMT write items error

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Help in RMT write items error

Postby Vader_Mester » Thu Apr 05, 2018 6:44 am

Hi All,

I'm using the RMT periferial to drive RGBW LEDs (similar to Neopixels).
For single channel everything seems to be OK, but if I want to assign multiple channels in an automated fastion, things are getting wrong.

So I use the following to define the RMT channels:

Code: Select all

//define ROW number RMT channel number. MAX number of channels is 8 (0-7), see rmt.h
#define ROW1 RMT_CHANNEL_0
#define ROW2 RMT_CHANNEL_1
#define ROW3 RMT_CHANNEL_2
#define ROW4 RMT_CHANNEL_3
#define ROW5 RMT_CHANNEL_4
#define ROW6 RMT_CHANNEL_5
#define ROW7 RMT_CHANNEL_6
#define ROW8 RMT_CHANNEL_7

//Configure the GPIO pins for each channel. Optimized for a Devkit
#define PIN1 13
#define PIN2 12
#define PIN3 12
#define PIN4 27
#define PIN5 5
#define PIN6 18
#define PIN7 19
#define PIN8 21

/*PIN CONFIG ON A DevKit.
*				      _   _   __
*				 	 | |_| |_| ||
*				---|EN         D23|---
*				---|VP         D22|---
*				---|VN         TX0|---
*				---|D34        RX0|---
*				---|D35        D21|---PIN8
*				---|D32        D19|---PIN7
*				---|D33        D18|---PIN6
*				---|D25         D5|---PIN5
*				---|D26        TX2|---
*			PIN1---|D27        RX2|---
*			PIN2---|D14         D4|---
*			PIN3---|D12         D2|---
*			PIN4---|D13        D15|---
*				---|GND        GND|---
*				---|VIN        3V3|---
*						|USB|
*/
Then created an array like this:

Code: Select all

uint8_t rmtpins[8] = {PIN1, PIN2, PIN3, PIN4, PIN5, PIN6, PIN7, PIN8};
uint8_t rownums[8] = {ROW1, ROW2, ROW3, ROW4, ROW5, ROW6, ROW7, ROW8};
Then use the following function to initialize and install the RMT driver:

Code: Select all

static bool initPixels(uint8_t numChan)
{
   rmt_config_t config[numChan];

   for(uint8_t i=0; i<numChan; i++){

       config[i].rmt_mode = RMT_MODE_TX;
       config[i].channel = i; // Could be defined via the enumeration: rmt_channel_t
       config[i].gpio_num = rmtpins[i];
       config[i].mem_block_num = i;
       config[i].tx_config.loop_en = 0;
       config[i].tx_config.carrier_en = 0; // disable carrier
       config[i].tx_config.idle_output_en = 1; // activate output while idle
       config[i].tx_config.idle_level = (rmt_idle_level_t)0; // output level to 0 when idle
       config[i].tx_config.carrier_duty_percent = 50; // must be set to prevent errors - not used
       config[i].tx_config.carrier_freq_hz = 10000; // must be set to prevent errors - not used
       config[i].tx_config.carrier_level = (rmt_carrier_level_t)0; // must be set to prevent errors - not used
       config[i].clk_div = DIVIDER;

      esp_err_t config_ok = rmt_config(&config[i]);
      if (config_ok != ESP_OK) {
         return 0;
      }

      esp_err_t install_ok = rmt_driver_install(config[i].channel, 0, 0);
      if (install_ok != ESP_OK) {
         return 0;
      }

   } // end for

   return 1;
}
Then when I use the rmt_write_items function (used in drawcolorsingle function)

Code: Select all

void app_main(void *ignore)
{
    if(initPixels(8)){
    while (1) {
    	for(uint8_t n = 0; n < 8; n++) {
    		for(uint8_t i = 0; i<10; i++) {		//here i is an index of a color array, nevermidn
    		drawcolorsingle(colorsdemo[i], rownums[n]);
        	vTaskDelay(100 / portTICK_PERIOD_MS);
    		}
    	}
    }
    vTaskDelete(NULL);
    }
}
Now when I start running this code, the LED connected to GPIO13, which should be RMT_CHANNEL_0, lights up perfectly as it should, but the rest don't and I'm getting this error in monitor:

Code: Select all

I (86) cpu_start: Pro cpu up.
I (86) cpu_start: Single core mode
I (86) heap_init: Initializing. RAM available for dynamic allocation:
I (89) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (95) heap_init: At 3FFB1EC8 len 0002E138 (184 KiB): DRAM
I (102) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (108) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (114) heap_init: At 400887FC len 00017804 (94 KiB): IRAM
I (120) cpu_start: Pro cpu start user code
II (138) cpu_start: Starting scheduler on PRO CPU.
E (4141) rmt: rmt_write_items(723): RMT DRIVER ERR
E (4241) rmt: rmtt_write_items(723): RMT DRIVER ERR
E (4341) rmt: rmt_write_items(723): RMT DRIVER ERR
E (4441) rmt: rmt_write_items(723): RMT DRIVER ERR
E (4541) rmt: rmt_write_items(723): RMT DRIVER ERR
.
.
.
What am I missing here?

Before this error, I used a single channel only, with a single row of LEDs, everything worked fine, maybe I'm messing something trivial up in my "automation" and not noticing?

Thanks for the help in advance.

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

User avatar
PaulVdBergh
Posts: 58
Joined: Fri Feb 23, 2018 4:45 pm
Location: Brasschaat, Belgium

Re: Help in RMT write items error

Postby PaulVdBergh » Thu Apr 05, 2018 10:50 am

I'm not sure if it has something to do with the declaration of your pins, but you wrote

Code: Select all

#define PIN2 12
#define PIN3 12
So PIN2 and PIN3 both point to the same output pin?

Hope this helps....
Paul.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Help in RMT write items error

Postby Vader_Mester » Thu Apr 05, 2018 11:22 am

Good eyeballs there ;)
Thanks for pointing to this. Maybe it's not the issue, I have to check.
Logically it is possible to output 2 channels on the same GPIO, but.... let's see if it works that way.

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

Who is online

Users browsing this forum: Baidu [Spider] and 45 guests