RMT: Discussion on "item_number" with rmt_write_items()

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

RMT: Discussion on "item_number" with rmt_write_items()

Postby kolban » Tue Jan 10, 2017 4:02 am

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?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Tue Jan 10, 2017 4:58 am

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

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

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

Postby kolban » Tue Jan 10, 2017 5:16 am

Do you think the documentation should be updated to make this understanding clearer?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: No registered users and 117 guests