ESP32C6 RMT RX help needed
Posted: 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.
Serial output...
Any help appreciated.
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);
};
}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