Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TW#15165] RMT isn't working correctly on master #949

Closed
MartyMacGyver opened this issue Sep 1, 2017 · 3 comments
Closed

[TW#15165] RMT isn't working correctly on master #949

MartyMacGyver opened this issue Sep 1, 2017 · 3 comments

Comments

@MartyMacGyver
Copy link

The RMT device is no longer transmitting as expected in transmit mode.

This isn't working for my code:
https://github.com/MartyMacGyver/ESP32-Digital-RGB-LED-Drivers

Nor is it working against the code my code was originally based upon:
https://github.com/FozzTexx/ws2812-demo

As was reported to me via MartyMacGyver/ESP32-Digital-RGB-LED-Drivers#9, undoing commit 17747b3 rectifies the problem. It's not yet clear whether there is a bug in that commit or if there is extra code required to work successfully based upon it.

For reference, there was some discussion here but it was inconclusive:
https://www.esp32.com/viewtopic.php?f=13&t=2339&p=11273

@MartyMacGyver
Copy link
Author

MartyMacGyver commented Sep 1, 2017

This may be resolved now - at least, it seems to be working for me.

Both our demos used the old GPIO constuction:

....
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_RMT_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_RMT_RST);
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[gpioNum], 2);
gpio_matrix_out((gpio_num_t)gpioNum, RMT_SIG_OUT0_IDX + RMTCHANNEL, 0, 0);
gpio_set_direction((gpio_num_t)gpioNum, GPIO_MODE_OUTPUT);
...RMT initialization code follows...

Using the rmt_set_pin() (from driver/rmt.h) instead seems to resolve the issue:

....
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_RMT_CLK_EN);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_RMT_RST);
rmt_set_pin(static_cast<rmt_channel_t>(RMTCHANNEL),
            RMT_MODE_TX,
            static_cast<gpio_num_t>(gpioNum));
...RMT initialization code follows...

Edit: one needs to include drivers/rmt.h to use this. If you're using C, use C-style casts instead of static_cast<type> e.g. (rmt_channel_t)RMTCHANNEL.

@FayeY FayeY changed the title RMT isn't working correctly on master [TW#15165] RMT isn't working correctly on master Sep 5, 2017
@igrr
Copy link
Member

igrr commented Sep 7, 2017

Previously, gpio_set_direction did not make sure that GPIO function was actually selected in the GPIO matrix. Now it switches to GPIO signal, which undoes the effect of gpio_matrix_out(..., RMT_SIG_OUT0_IDX + RMTCHANNEL, 0, 0);. Either switch the order of the two statements, or use rmt_set_pin as a higher-level solution, as you did.

@igrr igrr closed this as completed Sep 7, 2017
@MartyMacGyver
Copy link
Author

Thanks for the extra info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants