admin管理员组

文章数量:1406950

I am learning to use the esp32 for some projects. I was attempting to set up an rmt channel as per the documentation however when I try to create a new RMT channel I get an invalid argument error here is my code.

#include "driver/rmt_tx.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "esp_err.h"
#include <Arduino.h>

rmt_channel_handle_t tx_chan = NULL;

void setup() {
    Serial.begin(9600);
    
    
    rmt_tx_channel_config_t tx_chan_config = {
        .gpio_num = GPIO_NUM_16,              
        .clk_src = RMT_CLK_SRC_DEFAULT,       
        .resolution_hz = 1 * 1000 * 1000,     
        .mem_block_symbols = 4,             
    };

    esp_err_t err = rmt_new_tx_channel(&tx_chan_config, &tx_chan);
    if (err != ESP_OK) {
        Serial.printf("Error creating RMT TX channel: 0x%x\n", err);
    } else {
        Serial.println("RMT TX channel created successfully!");
    }
}

void loop() {
   
}

Here is the error I am getting when I upload to my esp32

DE (10) rmt: rmt_new_tx_channel(208): invalid argument

Error creating RMT TX channel: 0x102

If it matters I have a esp32 ESP-WROOM-32 ESP32 ESP-32S Development Board.

I tried making a rx channel to see if that was the issue but it threw the same error

I am learning to use the esp32 for some projects. I was attempting to set up an rmt channel as per the documentation however when I try to create a new RMT channel I get an invalid argument error here is my code.

#include "driver/rmt_tx.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "esp_err.h"
#include <Arduino.h>

rmt_channel_handle_t tx_chan = NULL;

void setup() {
    Serial.begin(9600);
    
    
    rmt_tx_channel_config_t tx_chan_config = {
        .gpio_num = GPIO_NUM_16,              
        .clk_src = RMT_CLK_SRC_DEFAULT,       
        .resolution_hz = 1 * 1000 * 1000,     
        .mem_block_symbols = 4,             
    };

    esp_err_t err = rmt_new_tx_channel(&tx_chan_config, &tx_chan);
    if (err != ESP_OK) {
        Serial.printf("Error creating RMT TX channel: 0x%x\n", err);
    } else {
        Serial.println("RMT TX channel created successfully!");
    }
}

void loop() {
   
}

Here is the error I am getting when I upload to my esp32

DE (10) rmt: rmt_new_tx_channel(208): invalid argument

Error creating RMT TX channel: 0x102

If it matters I have a esp32 ESP-WROOM-32 ESP32 ESP-32S Development Board.

I tried making a rx channel to see if that was the issue but it threw the same error

Share edited Mar 7 at 0:34 hcheung 4,0983 gold badges15 silver badges27 bronze badges asked Mar 6 at 19:19 turkrkrkrrkrkrkrkrturkrkrkrrkrkrkrkr 93 bronze badges 4
  • You may want to consider posting to Arduino. – Thomas Matthews Commented Mar 6 at 19:28
  • Be really nice if the error could tell you which argument was invalid. Right about now I'd be digging through the device documentation to ensure the values I provided were supported by the device. – user4581301 Commented Mar 6 at 19:28
  • Note that there are members in tx_chan_config that are not being set. As of C++20, the initialization rules for the skipped members rules are well defined, but I can't give any guarantees before that because the Standard doesn't recognize the syntax. – user4581301 Commented Mar 6 at 19:37
  • Quick hack check: Print out the values of ALL of the tx_chan_config members and make sure all of them are being initialized to valid values. – user4581301 Commented Mar 6 at 19:44
Add a comment  | 

1 Answer 1

Reset to default 1

The complete rmt_tx_channel_config_t object should look like this:

    rmt_tx_channel_config_t tx_chan_config = {
        .gpio_num = GPIO_NUM_16,              
        .clk_src = RMT_CLK_SRC_DEFAULT,       
        .resolution_hz = 1 * 1000 * 1000,     
        .mem_block_symbols = 64, 
        .trans_queue_depth = 4            
    };
  1. You are missing the .trans_queue_depth setting.

  2. The mem_block_symbols need to be at least 64 (i.e. 64 * 4 = 256 bytes).

本文标签: arduinotrouble setting up a rmt channelStack Overflow