duration in rmt_item32_t Uint32 or int16 ?

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

duration in rmt_item32_t Uint32 or int16 ?

Postby jumjum123 » Mon Jun 26, 2017 5:07 pm

During test with rmt_item32_t values greater than 32767 are not handled correct.
Using 50000 for example, in reality 17232 is used.
For me this looks like int16 is used instead of Uint32_t

Is this assumption correct ?

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

Re: duration in rmt_item32_t Uint32 or int16 ?

Postby kolban » Mon Jun 26, 2017 5:15 pm

I think the high level answer is neither 16 or 32 bit :-) ...

With RMT, one defines the signal level (1 or 0) and a duration. This is encoded in a 16 bit value .... so we have 1 bit for the level and 15 bits for the duration. This gives us a maximum duration of 32767.

Each RMT "element" consists of one of these 16 bit values ... however, the ESP32 is a 32 bit device and really wants to move things around in units of 32 bits. As such, the data type known as rmt_item32_t contains TWO 16 bit elements. These are referred to as:

* item.level0
* item.duration0
* item.level1
* item.duration1

As such, you shouldn't treat an rmt_item32_t as a single element ... but rather a unit of 2 elements. And you should think of the maximum duration as being 15 bits and not 16 bits.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Baidu [Spider] and 128 guests