Page 1 of 1

RMT simple callback encoder usage example/explanation

Posted: Fri Dec 27, 2024 3:19 am
by calvong
Hi,

Is there any example for the RMT simple callback encoder: https://docs.espressif.com/projects/esp ... ck-encoder? From the documentation, I still don't fully understand how the encoder callback works, so I'd love to see a working example. More specifically, I am interested in generating a "long" waveform using RMT, which means it needs to be transmitted in chunks. In the doc,
If the space is not enough for the callback to encode something, it can return 0 and the RMT will wait for previous symbols to be transmitted and call the callback again, now with more space available.

Does that mean I have filled up/encoded a chunk of data, I need it transmit it first, then reset the encoder? then repeat? Or what are the steps I need to do? Any pseudocode on how I can use the simple callback encoder for this would be greatly appreciated as well! :)

Thanks!

Re: RMT simple callback encoder usage example/explanation

Posted: Fri Dec 27, 2024 4:37 am
by ESP_Sprite
The driver comes with this example, hope that helps.

In general, the callback you provide will get called whenever there is some RMT memory that needs filling: in the callback, you calculate the next bit of your waveform and put it in the provided memory. The provided amount of memory can be anywhere between 1 entry and the maximum buffer the RMT can give you. If the amount of memory is too little (for instance, you can only calculate your waveform in increments of 2 RMT entries), your callback can return 0 and it will be called again later when there is more RMT memory available.