Problem creating 2 Tx channels on ESP32C3

Yossarian
Posts: 3
Joined: Sun Oct 16, 2022 10:31 am

Problem creating 2 Tx channels on ESP32C3

Postby Yossarian » Sun Oct 16, 2022 10:44 am

Hi Guys

I’m trying to build a twin channel pulse generator which uses the fancy RMT synchronise function. Apparently the ESP32 itself doesn’t possess the required synchronization hardware, but the ESP32C3 does.

My problem is that I cant even get the ESP32C3 to install two channels. The simple code below runs fine on the ESP32 but not on my Xiao seed studio ESP32C3. I’m using esp-idf-v5.0 here.

Any suggestions would be appreciated. Thank you

Here's the code that works fine on the ESP32 but not on the ESP32C3

Code: Select all

#include "driver/rmt_tx.h"
#include "esp_log.h"

#define RMT_RESOLUTION 1 * 1000 * 1000  /* 1MHz, ie 1 tick = 1 microsecond */
int tx_gpio_number[2] = {9,10};
static const char *TAG = "Test Pulse Generator";

void app_main(void)
{
    ESP_LOGI(TAG, "Create RMT TX channel");
    rmt_channel_handle_t tx_channels[2] = {NULL};       // declare two channels

    // install channels one by one
for (int i = 0; i < 2; i++) {
    rmt_tx_channel_config_t tx_chan_config = {
        .clk_src = RMT_CLK_SRC_DEFAULT,         
        .gpio_num = tx_gpio_number[i],          
        .mem_block_symbols = 64,               
        .resolution_hz = RMT_RESOLUTION,       
        .trans_queue_depth = 1,               
    };
    ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &tx_channels[i]));
}
}
The output on the ESP32 looks like this

Code: Select all

I (309) Test Pulse Generator: Create RMT TX channel
I (319) gpio: GPIO[9]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (329) gpio: GPIO[10]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
Whereas the output on the ESP32C3 looks like this:

Code: Select all

I (251) Test Pulse Generator: Create RMT TX channel
I (251) gpio: GPIO[9]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
E (261) rmt: rmt_tx_register_to_group(131): no free tx channels
E (271) rmt: rmt_new_tx_channel(231): register channel failed
ESP_ERROR_CHECK failed: esp_err_t 0x105 (ESP_ERR_NOT_FOUND) at 0x42006b3c
0x42006b3c: app_main at C:/Users/Patrick/Documents/my_projects/pulse_sequence_testing/main/twinChannels.c:23 (discriminator 1)
I'm pretty sure that the ESP32C3 does have two channels because it says so in the TRM (technical reference manual) What am I doing wrong?

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: Problem creating 2 Tx channels on ESP32C3

Postby ESP_Sprite » Sun Oct 16, 2022 10:55 am

Can you try if setting mem_block_symbols to 32 helps?

Yossarian
Posts: 3
Joined: Sun Oct 16, 2022 10:31 am

Re: Problem creating 2 Tx channels on ESP32C3

Postby Yossarian » Tue Oct 18, 2022 9:50 pm

Yes - Thank you!

You solved the problem. mem_block_symbols = 32, but I got the error:

Code: Select all

I (238) Test Pulse Generator: Create RMT TX channel
E (238) rmt: rmt_new_tx_channel(210): mem_block_symbols must be even and at least 48
ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x42006b3c
So I changed it to 48 and it worked fine!

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], ignisuti and 97 guests