RMT channel 0 with full 512x32-bit memory fails

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

RMT channel 0 with full 512x32-bit memory fails

Postby loboris » 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.
Channel0 can use at most 8 blocks of memory, accordingly channel7 can only use one memory block.
If we use 8 memory blocks for the channel 0, it passes the check in rmt_config() (rmt.c, line 393):

Code: Select all

RMT_CHECK((mem_cnt + channel <= 8 && mem_cnt > 0), RMT_MEM_CNT_ERROR_STR, ESP_ERR_INVALID_ARG);
In function rmt_write_items() (rmt.c, line 721) item_sub_len is calculated to the value of 256 (8*64 / 2).

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;
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):

Code: Select all

RMT_CHECK(evt_thresh < 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG);
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...

Who is online

Users browsing this forum: No registered users and 134 guests