RMT simple callback encoder usage example/explanation

calvong
Posts: 2
Joined: Fri Dec 27, 2024 2:52 am

RMT simple callback encoder usage example/explanation

Postby calvong » Fri Dec 27, 2024 3:19 am

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!

ESP_Sprite
Posts: 9883
Joined: Thu Nov 26, 2015 4:08 am

Re: RMT simple callback encoder usage example/explanation

Postby ESP_Sprite » Fri Dec 27, 2024 4:37 am

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.

Who is online

Users browsing this forum: No registered users and 70 guests