Page 1 of 1

RMT: Discussion on "item_number" with rmt_write_items()

Posted: Tue Jan 10, 2017 4:02 am
by kolban
I'm studying the RMT peripheral and so far enjoying it. While reading the docs on the driver function called "rmt_write_items()" I find myself confused on the parameter called "item_number". See here:

http://esp-idf.readthedocs.io/en/latest ... item32_tib

Let me try and explain ...

The RMT works with items. An item is a 16 bit value where 1 bit indicates high vs low and the remaining 15 bits describe a duration in clock ticks where that signal level will be generated.

The driver however works in data structures called "rmt_item32_t" which are TWO instances of an RMT item contained in 32 bits (2 x 16 bits).

The RMT peripheral consumes RMT items one at a time until it finds an end marker indicated by an item having a duration of length 0.

Hopefully ... all of this so far is simply statement of fact.

Now let us look at the rmt_write_items() API. Among other things it takes a pointer to an array of rmt_item32_t and ... the "item_num". The docs on the "item_num" literally say "RMT data item number". And that's it.

And here's where the confusion comes in. Is this:

a) The number of RMT items being supplied?
b) The number of rmt_item32_t records being supplied?
c) Something else

And ... finally ... given what I said (and believe to be the case) earlier ... why do we need a length when the data has to be self terminated?

Re: RMT: Discussion on "item_number" with rmt_write_items()

Posted: Tue Jan 10, 2017 4:58 am
by WiFive
b) The number of rmt_item32_t records being supplied

The length is so that the function knows how many items it will copy into the peripheral memory internal queue and whether it will require more than 1 copy operation. Only the peripheral itself is looking for the terminator.

https://github.com/espressif/esp-idf/bl ... nec.c#L336

Re: RMT: Discussion on "item_number" with rmt_write_items()

Posted: Tue Jan 10, 2017 5:16 am
by kolban
Do you think the documentation should be updated to make this understanding clearer?