RMT channel 0 with full 512x32-bit memory fails
Posted: Wed Sep 20, 2017 9:13 am
I have an issue when using RMT channel 0 with 8 memory blocks (512x32-bit). The operation fails with "RMT EVT THRESH ERR" error.
I think it is caused by the bug in rmt_set_tx_thr_intr_en function (esp-idf/components/driver/rmt.c)
Here is the short analysis of the problem:
mem_block_num config option sets the number of the memory blocks (64*32 bits) to be usesd for the RMT channel.
In function rmt_write_items() (rmt.c, line 721) item_sub_len is calculated to the value of 256 (8*64 / 2).
rmt_set_tx_thr_intr_en(channel, 1, item_sub_len) function is called (rmt.c, line 733) with that value, and fails because of the the check (rmt.c, line 354):
If the check is changed to:
RMT_CHECK(evt_thresh <= 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG);
everything works as expected.
I know it is probably the rare case that only the cnannel 0 is used with 8 memory blocks, but it should work...
I think it is caused by the bug in rmt_set_tx_thr_intr_en function (esp-idf/components/driver/rmt.c)
Here is the short analysis of the problem:
mem_block_num config option sets the number of the memory blocks (64*32 bits) to be usesd for the RMT channel.
If we use 8 memory blocks for the channel 0, it passes the check in rmt_config() (rmt.c, line 393):Channel0 can use at most 8 blocks of memory, accordingly channel7 can only use one memory block.
Code: Select all
RMT_CHECK((mem_cnt + channel <= 8 && mem_cnt > 0), RMT_MEM_CNT_ERROR_STR, ESP_ERR_INVALID_ARG);
Code: Select all
int block_num = RMT.conf_ch[channel].conf0.mem_size;
int item_block_len = block_num * RMT_MEM_ITEM_NUM;
int item_sub_len = block_num * RMT_MEM_ITEM_NUM / 2;
Code: Select all
RMT_CHECK(evt_thresh < 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG);
RMT_CHECK(evt_thresh <= 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG);
everything works as expected.
I know it is probably the rare case that only the cnannel 0 is used with 8 memory blocks, but it should work...