ESP32C6 RMT RX help needed

h00die
Posts: 1
Joined: Wed Jun 11, 2025 2:29 pm

ESP32C6 RMT RX help needed

Postby h00die » Wed Jun 11, 2025 2:43 pm

Hi all - I have an ESP32C6-Devkit-C board and am attempting to get RMT to work within the Arduino IDE. My code compiles clean, and I get no errors during setup() when allocating the RMT RX channel but after setup I don't see the rmt listener allocated in the GPIO matrix. I DO get errors on loop() trying to read the channel saying it is not in init or enable state.

I'm not able to get verbose logging to work within the Arduino IDE for some reason which I think is a known problem with the debug macros(?), so I can't get any more detailed information from the rmt_rx.c code to track this down. So I guess my question is: anything obvious I am missing here, and is there some way to get the verbose logging to work again?

This signal I'm trying to read has a 7.5ms LOW start (or stop depending on which side you're catching), with zero being ~600us, one being 1.5ms, and a logic HIGH between signals of ~750us. Not that is matters yet as I can't get this far.

Code: Select all

#include <Arduino.h>
#include <driver/rmt_rx.h>

rmt_channel_handle_t rx_chan = NULL;

rmt_rx_channel_config_t rx_chan_config = {
    .gpio_num = GPIO_NUM_10,          // GPIO number
    .clk_src = RMT_CLK_SRC_DEFAULT,   // select source clock
    .resolution_hz = 1 * 1000 * 1000, // 1 MHz tick resolution, i.e., 1 tick = 1 µs
    .mem_block_symbols = 64,          // memory block size, 64 * 4 = 256 Bytes
    .intr_priority = 0,
    .flags = {
      .invert_in = true,
      .with_dma = false,
      .io_loop_back = false
    }
};

rmt_receive_config_t rx_recv_config = {
  .signal_range_min_ns = 0,     // the shortest duration for a binary 0
  .signal_range_max_ns = 750000  // skywalker preamble
};

// circular buffer to hold messages
QueueHandle_t receive_queue = xQueueCreate(1, sizeof(rmt_rx_done_event_data_t));

// rmt_rx callback
static bool rmt_rx_done_callback(rmt_channel_handle_t channel, const rmt_rx_done_event_data_t *edata, void *user_data)
{
    BaseType_t high_task_wakeup = pdFALSE;
    QueueHandle_t receive_queue = (QueueHandle_t)user_data;
    // send the received RMT symbols to the parser task
    xQueueSendFromISR(receive_queue, edata, &high_task_wakeup);
    // return whether any task is woken up
    return high_task_wakeup == pdTRUE;
}

// assign rmt_rx callback as handler rmt_rx_done event
rmt_rx_event_callbacks_t cbs = {
    .on_recv_done = rmt_rx_done_callback,
};

static void parse_frame(rmt_symbol_word_t *rmt_nec_symbols, size_t symbol_num)
{
  Serial.printf("NEC frame start---\r\n");
  for (size_t i = 0; i < symbol_num; i++) {
      Serial.printf("{%d:%d},{%d:%d}\r\n", rmt_nec_symbols[i].level0, rmt_nec_symbols[i].duration0,
              rmt_nec_symbols[i].level1, rmt_nec_symbols[i].duration1);
  }
  Serial.printf("---NEC frame end: ");
}

void setup() {
  Serial.begin(115200);
  while (!Serial);
  Serial.println("Starting...");
  delay(5000);

  // instantiate rx channel
  ESP_LOGI("setup", "create rx chan", NULL);
  ESP_ERROR_CHECK(rmt_new_rx_channel(&rx_chan_config, &rx_chan));

  // register rx callback
  ESP_LOGI("setup", "register rx callback", NULL);
  ESP_ERROR_CHECK(rmt_rx_register_event_callbacks(rx_chan, &cbs, receive_queue));

  ESP_LOGI("setup", "enable rx chan", NULL);
  ESP_ERROR_CHECK(rmt_enable(rx_chan));
}

void loop() {
  delay(1000);
  // allocate buffer
  rmt_symbol_word_t raw_symbols[64];
  
  // give time to rmt to fetch a signal into the buffer
  ESP_LOGI("loop", "read");
  ESP_ERROR_CHECK(rmt_enable(rx_chan));
  ESP_ERROR_CHECK(rmt_receive(rx_chan, raw_symbols, sizeof(raw_symbols), &rx_recv_config));

  // fetch any rx frames from the buffer
  rmt_rx_done_event_data_t rx_data;
  if( xQueueReceive(receive_queue, &rx_data, 0) ) { //if we got a message
    //parse it
    parse_frame(rx_data.received_symbols, rx_data.num_symbols);
  };
}
Serial output...

Code: Select all

07:40:15.156 -> =========== Before Setup Start ===========
07:40:15.156 -> Chip Info:
07:40:15.156 -> ------------------------------------------
07:40:15.156 ->   Model             : ESP32-C6
07:40:15.156 ->   Package           : 0
07:40:15.156 ->   Revision          : 0.01
07:40:15.156 ->   Cores             : 1
07:40:15.156 ->   CPU Frequency     : 160 MHz
07:40:15.156 ->   XTAL Frequency    : 40 MHz
07:40:15.156 ->   Features Bitfield : 0x00000052
07:40:15.156 ->   Embedded Flash    : No
07:40:15.156 ->   Embedded PSRAM    : No
07:40:15.156 ->   2.4GHz WiFi       : Yes
07:40:15.156 ->   Classic BT        : No
07:40:15.156 ->   BT Low Energy     : Yes
07:40:15.156 ->   IEEE 802.15.4     : Yes
07:40:15.156 -> ------------------------------------------
07:40:15.156 -> INTERNAL Memory Info:
07:40:15.156 -> ------------------------------------------
07:40:15.156 ->   Total Size        :   470940 B ( 459.9 KB)
07:40:15.156 ->   Free Bytes        :   436608 B ( 426.4 KB)
07:40:15.156 ->   Allocated Bytes   :    27828 B (  27.2 KB)
07:40:15.156 ->   Minimum Free Bytes:   431796 B ( 421.7 KB)
07:40:15.156 ->   Largest Free Block:   401396 B ( 392.0 KB)
07:40:15.156 -> ------------------------------------------
07:40:15.156 -> Flash Info:
07:40:15.156 -> ------------------------------------------
07:40:15.177 ->   Chip Size         :  8388608 B (8 MB)
07:40:15.177 ->   Block Size        :    65536 B (  64.0 KB)
07:40:15.177 ->   Sector Size       :     4096 B (   4.0 KB)
07:40:15.177 ->   Page Size         :      256 B (   0.2 KB)
07:40:15.177 ->   Bus Speed         : 40 MHz
07:40:15.177 ->   Bus Mode          : QIO
07:40:15.177 -> ------------------------------------------
07:40:15.177 -> Partitions Info:
07:40:15.177 -> ------------------------------------------
07:40:15.177 ->                 nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
07:40:15.177 ->             otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
07:40:15.177 ->                app0 : addr: 0x00010000, size:  1280.0 KB, type:  APP, subtype: OTA_0
07:40:15.177 ->                app1 : addr: 0x00150000, size:  1280.0 KB, type:  APP, subtype: OTA_1
07:40:15.177 ->              spiffs : addr: 0x00290000, size:  1408.0 KB, type: DATA, subtype: SPIFFS
07:40:15.177 ->            coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
07:40:15.177 -> ------------------------------------------
07:40:15.177 -> Software Info:
07:40:15.177 -> ------------------------------------------
07:40:15.177 ->   Compile Date/Time : Jun  8 2025 08:38:37
07:40:15.177 ->   Compile Host OS   : macosx
07:40:15.177 ->   ESP-IDF Version   : v5.4.1-1-g2f7dcd862a-dirty
07:40:15.177 ->   Arduino Version   : 3.2.0
07:40:15.177 -> ------------------------------------------
07:40:15.177 -> Board Info:
07:40:15.177 -> ------------------------------------------
07:40:15.177 ->   Arduino Board     : ESP32C6_DEV
07:40:15.177 ->   Arduino Variant   : esp32c6
07:40:15.177 ->   Arduino FQBN      : esp32:esp32:esp32c6:UploadSpeed=921600,CDCOnBoot=cdc,CPUFreq=160,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=verbose,EraseFlash=none,JTAGAdapter=builtin,ZigbeeMode=default
07:40:15.177 -> ============ Before Setup End ============
07:40:15.177 -> [   737][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 12 already has type USB_DM (38) with bus 0x4080ead0
07:40:15.210 -> [   737][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 13 already has type USB_DP (39) with bus 0x4080ead0
07:40:15.210 -> Starting...
07:40:20.199 -> [  5738][I][sketch_jun5a.ino:60] setup(): [setup] create rx chan
07:40:20.199 -> [  5738][I][sketch_jun5a.ino:64] setup(): [setup] register rx callback
07:40:20.199 -> [  5738][I][sketch_jun5a.ino:67] setup(): [setup] enable rx chan
07:40:20.199 -> =========== After Setup Start ============
07:40:20.199 -> INTERNAL Memory Info:
07:40:20.199 -> ------------------------------------------
07:40:20.199 ->   Total Size        :   470940 B ( 459.9 KB)
07:40:20.199 ->   Free Bytes        :   436104 B ( 425.9 KB)
07:40:20.199 ->   Allocated Bytes   :    28204 B (  27.5 KB)
07:40:20.199 ->   Minimum Free Bytes:   431796 B ( 421.7 KB)
07:40:20.199 ->   Largest Free Block:   401396 B ( 392.0 KB)
07:40:20.199 -> ------------------------------------------
07:40:20.199 -> GPIO Info:
07:40:20.199 -> ------------------------------------------
07:40:20.199 ->   GPIO : BUS_TYPE[bus/unit][chan]
07:40:20.199 ->   --------------------------------------  
07:40:20.199 ->     12 : USB_DM
07:40:20.199 ->     13 : USB_DP
07:40:20.199 ->     16 : UART_TX[0]
07:40:20.199 ->     17 : UART_RX[0]
07:40:20.199 -> ============ After Setup End =============
07:40:21.235 -> [  6767][I][sketch_jun5a.ino:77] loop(): [loop] read
07:40:21.235 -> E (6967) rmt: rmt_rx_enable(513): channel not in init state
07:40:22.207 -> [  7767][I][sketch_jun5a.ino:77] loop(): [loop] read
07:40:22.207 -> E (7967) rmt: rmt_rx_enable(513): channel not in init state
07:40:22.207 -> E (7967) rmt: rmt_receive(419): channel not in enable state
07:40:23.243 -> [  8772][I][sketch_jun5a.ino:77] loop(): [loop] read
07:40:23.243 -> E (8972) rmt: rmt_rx_enable(513): channel not in init state
07:40:23.243 -> E (8972) rmt: rmt_receive(419): channel not in enable state
07:40:24.243 -> [  9772][I][sketch_jun5a.ino:77] loop(): [loop] read
07:40:24.243 -> E (9972) rmt: rmt_rx_enable(513): channel not in init state
07:40:24.243 -> E (9972) rmt: rmt_receive(419): channel not in enable state
07:40:25.247 -> [ 10777][I][sketch_jun5a.ino:77] loop(): [loop] read
07:40:25.247 -> E (10977) rmt: rmt_rx_enable(513): channel not in init state
07:40:25.247 -> E (10977) rmt: rmt_receive(419): channel not in enable state
Any help appreciated.

h00die
Posts: 1
Joined: Wed Jun 11, 2025 2:29 pm

Re: ESP32C6 RMT RX help needed

Postby h00die » Sat Jun 14, 2025 5:59 pm

If I switch to the older style rmtInit() interface, it works...

...the code...

Code: Select all

#include "Arduino.h"

#define RMT_RX_PIN GPIO_NUM_10
#define RMT_MEM_RX RMT_MEM_NUM_BLOCKS_2

rmt_data_t my_data[256];
rmt_data_t data[256];

#define RMT_FREQ               10000000  // tick time is 100ns
#define RMT_NUM_EXCHANGED_DATA 32

void setup() {
  Serial.begin(115200);

  if (!rmtInit(RMT_RX_PIN, RMT_RX_MODE, RMT_MEM_RX, RMT_FREQ)) {
    Serial.println("init receiver failed\n");
  }
  Serial.println();
  Serial.println("RMT tick set to: 100ns");

  // End of transmission shall be detected when line is idle for 2us = 20*100ns
  rmtSetRxMaxThreshold(RMT_RX_PIN, 7500);
  rmtSetRxMinThreshold(RMT_RX_PIN, 0);
}

void loop() {
  // Start an async data read
  size_t rx_num_symbols = RMT_NUM_EXCHANGED_DATA;
  rmtReadAsync(RMT_RX_PIN, my_data, &rx_num_symbols);

  // Wait until data is read
  while (!rmtReceiveCompleted(RMT_RX_PIN));

  // Once data is available, the number of RMT Symbols is stored in rx_num_symbols
  // and the received data is copied to my_data
  Serial.printf("Got %d RMT symbols\n", rx_num_symbols);

  // Printout the received data plus the original values
  for (int i = 0; i < RMT_NUM_EXCHANGED_DATA; i++) {
    Serial.printf("%08lx=%08lx ", my_data[i].val, data[i].val);
    if (!((i + 1) % 4)) {
      Serial.println();
    }
  }
  Serial.println();

  delay(2000);
}
...the output - note RMT is initted successfully in the gpio matrix on setup().

Code: Select all

10:54:03.545 -> =========== Before Setup Start ===========
10:54:03.545 -> Chip Info:
10:54:03.545 -> ------------------------------------------
10:54:03.545 ->   Model             : ESP32-C6
10:54:03.545 ->   Package           : 0
10:54:03.545 ->   Revision          : 0.01
10:54:03.545 ->   Cores             : 1
10:54:03.545 ->   CPU Frequency     : 160 MHz
10:54:03.545 ->   XTAL Frequency    : 40 MHz
10:54:03.545 ->   Features Bitfield : 0x00000052
10:54:03.545 ->   Embedded Flash    : No
10:54:03.545 ->   Embedded PSRAM    : No
10:54:03.545 ->   2.4GHz WiFi       : Yes
10:54:03.545 ->   Classic BT        : No
10:54:03.545 ->   BT Low Energy     : Yes
10:54:03.545 ->   IEEE 802.15.4     : Yes
10:54:03.545 -> ------------------------------------------
10:54:03.545 -> INTERNAL Memory Info:
10:54:03.545 -> ------------------------------------------
10:54:03.545 ->   Total Size        :   468924 B ( 457.9 KB)
10:54:03.545 ->   Free Bytes        :   435376 B ( 425.2 KB)
10:54:03.545 ->   Allocated Bytes   :    27156 B (  26.5 KB)
10:54:03.545 ->   Minimum Free Bytes:   430652 B ( 420.6 KB)
10:54:03.545 ->   Largest Free Block:   401396 B ( 392.0 KB)
10:54:03.545 -> ------------------------------------------
10:54:03.545 -> Flash Info:
10:54:03.545 -> ------------------------------------------
10:54:03.545 ->   Chip Size         :  8388608 B (8 MB)
10:54:03.545 ->   Block Size        :    65536 B (  64.0 KB)
10:54:03.545 ->   Sector Size       :     4096 B (   4.0 KB)
10:54:03.545 ->   Page Size         :      256 B (   0.2 KB)
10:54:03.545 ->   Bus Speed         : 40 MHz
10:54:03.545 ->   Bus Mode          : QIO
10:54:03.545 -> ------------------------------------------
10:54:03.545 -> Partitions Info:
10:54:03.545 -> ------------------------------------------
10:54:03.545 ->                 nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
10:54:03.545 ->             otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
10:54:03.545 ->                app0 : addr: 0x00010000, size:  1280.0 KB, type:  APP, subtype: OTA_0
10:54:03.545 ->                app1 : addr: 0x00150000, size:  1280.0 KB, type:  APP, subtype: OTA_1
10:54:03.545 ->              spiffs : addr: 0x00290000, size:  1408.0 KB, type: DATA, subtype: SPIFFS
10:54:03.545 ->            coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
10:54:03.545 -> ------------------------------------------
10:54:03.545 -> Software Info:
10:54:03.545 -> ------------------------------------------
10:54:03.545 ->   Compile Date/Time : Jun 11 2025 10:09:47
10:54:03.545 ->   Compile Host OS   : macosx
10:54:03.545 ->   ESP-IDF Version   : v5.4.1-1-g2f7dcd862a-dirty
10:54:03.545 ->   Arduino Version   : 3.2.0
10:54:03.545 -> ------------------------------------------
10:54:03.545 -> Board Info:
10:54:03.545 -> ------------------------------------------
10:54:03.545 ->   Arduino Board     : ESP32C6_DEV
10:54:03.545 ->   Arduino Variant   : esp32c6
10:54:03.545 ->   Arduino FQBN      : esp32:esp32:esp32c6:UploadSpeed=921600,CDCOnBoot=cdc,CPUFreq=160,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=debug,EraseFlash=all,JTAGAdapter=builtin,ZigbeeMode=default
10:54:03.545 -> ============ Before Setup End ============
10:54:03.641 -> [   858][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 12 already has type USB_DM (38) with bus 0x4080f2b0
10:54:03.641 -> [   858][I][esp32-hal-periman.c:141] perimanSetPinBus(): Pin 13 already has type USB_DP (39) with bus 0x4080f2b0
10:54:03.641 -> [   859][I][esp32-hal-rmt.c:454] rmtInit(): [rmt] GPIO 10 - RX MODE - MemSize[96] - Freq=10000000Hz
10:54:03.641 -> 
10:54:03.641 -> RMT tick set to: 100ns
10:54:03.641 -> =========== After Setup Start ============
10:54:03.641 -> INTERNAL Memory Info:
10:54:03.641 -> ------------------------------------------
10:54:03.641 ->   Total Size        :   468924 B ( 457.9 KB)
10:54:03.641 ->   Free Bytes        :   434508 B ( 424.3 KB)
10:54:03.641 ->   Allocated Bytes   :    27816 B (  27.2 KB)
10:54:03.641 ->   Minimum Free Bytes:   430652 B ( 420.6 KB)
10:54:03.641 ->   Largest Free Block:   401396 B ( 392.0 KB)
10:54:03.641 -> ------------------------------------------
10:54:03.641 -> GPIO Info:
10:54:03.641 -> ------------------------------------------
10:54:03.641 ->   GPIO : BUS_TYPE[bus/unit][chan]
10:54:03.641 ->   --------------------------------------  
10:54:03.641 ->     10 : RMT_RX
10:54:03.641 ->     12 : USB_DM
10:54:03.641 ->     13 : USB_DP
10:54:03.641 ->     16 : UART_TX[0]
10:54:03.641 ->     17 : UART_RX[0]
10:54:03.641 -> ============ After Setup End =============
10:54:03.673 -> [   884][I][esp32-hal-rmt.c:377] _rmtRead(): [rmt] GPIO: 10 - Request: 32 RMT Symbols - Non-Blocking - Timeout: 0
10:54:37.277 -> Got 1 RMT symbols
10:54:37.277 -> 80000001=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.277 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.310 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.310 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.310 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.310 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.310 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.310 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:37.310 -> 
10:54:39.299 -> [ 36508][I][esp32-hal-rmt.c:377] _rmtRead(): [rmt] GPIO: 10 - Request: 32 RMT Symbols - Non-Blocking - Timeout: 0
10:54:39.299 -> Got 1 RMT symbols
10:54:39.299 -> 00009d4b=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:39.299 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:39.299 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:39.299 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:39.299 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:39.299 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:39.299 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:39.299 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000
10:54:43.305 ->  
10:54:45.330 -> [ 42532][I][esp32-hal-rmt.c:377] _rmtRead(): [rmt] GPIO: 10 - Request: 32 RMT Symbols - Non-Blocking - Timeout: 0
10:54:45.330 -> Got 4 RMT symbols
10:54:45.330 -> 9d46186c=00000000 9d44186e=00000000 9d45186a=00000000 80001874=00000000 
10:54:45.330 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:45.330 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:45.330 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:45.330 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:45.330 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:45.330 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
10:54:45.330 -> 00000000=00000000 00000000=00000000 00000000=00000000 00000000=00000000 
Is there a reason why the newer interface doesn't work, and doesn't provide logging output, whereas the older style does?
Last edited by h00die on Sat Jun 14, 2025 6:01 pm, edited 1 time in total.

Who is online

Users browsing this forum: No registered users and 1 guest