Hello!
I am using the RMT peripheral to drive RGB LEDs, and I have a general driver for the FastLED library that supports up to eight outputs using the eight available RMT channels.
Recently, I have been working on a new version that supports more outputs by reusing RMT channels when they complete their transmission. For this to work, however, I need to be able to change the gpio pin associated with a particular RMT channel. What I am doing right now looks like this:
0. Attach two RGB strips (e.g., WS2812) to pins X and Y (the exact numbers are not important)
1. configure channel 0 for pin X
2. send all data on channel 0
3. change channel 0 to pin Y using rmt_set_pin
4. send all data on channel 1
I don't get any explicit errors, but the output is all mixed up. It looks sort of like the data is going to *both* pins in step (4) -- the LEDs are displaying the right colors, but on *both* strips.
For comparison, if I run the exact same code, but use a different RMT channel for steps (3) and (4), it all works perfectly.
Am I missing something here? Do I need to explicitly tell the gpio matrix thing *not* to use pin X anymore?
Any help would be greatly appreciated!
Thanks!
Using rmt_set_pin to change the pin bound to an RMT channel
-
- Posts: 9729
- Joined: Thu Nov 26, 2015 4:08 am
Re: Using rmt_set_pin to change the pin bound to an RMT channel
Effectively, 'configuring the RMT for a pin' configures the GPIO matrix to use the specified pin as an output for the RMT; it does not tell it to de-configure the output for the existing pin. (This allows you to output the same signal on multiple pins, as you inadvertently found out.) To de-configure the output, either tweak the GPIO matrix yourself (using gpio_matrix_out) or just configure the offending pin back into a GPIO by calling e.g. gpio_output_enable.
Re: Using rmt_set_pin to change the pin bound to an RMT channel
That worked! I used the following call to turn off output to the old pin:
Thank you!
Code: Select all
gpio_matrix_out(old_pin, 0x100, 0, 0);
Re: Using rmt_set_pin to change the pin bound to an RMT channel
Instead of rmt_set_pin (and rmt_clear_pin, which I don't know if it exists), you may be using
Code: Select all
pinMode(pin, OUTPUT);
pinMatrixOutAttach(pin, RMT_SIG_OUT0_IDX + chan, 0, 0);
.. use chan with pin, then
pinMatrixOutDetach(pin, 0, 0);
Who is online
Users browsing this forum: MicroController and 78 guests