-
Notifications
You must be signed in to change notification settings - Fork 7.6k
BUG RMT cannot be re-init after calling rmtDeinit #6363
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
Comments
a better test case #include "Arduino.h"
#define TACT_LED_IO 9
#define LED_QTY 1
#define BITS 24*LED_QTY
rmt_data_t led_data[BITS];
rmt_obj_t* rmt_send=NULL;
volatile int tactFlag=0,irqInit=0;
void IRAM_ATTR tactIsr(){
tactFlag=1;
}
void led_set(int r,int g,int b){
int color[3]={r,g,b};
int led=0, col, bit, i=0;
for (col = 0; col < 3; col++ ) {
for (bit = 0; bit < 8; bit++) {
if ( (color[col] & (1 << (7 - bit))) /*&& (led == led_index)*/ ) {
led_data[i].level0 = 1;
led_data[i].duration0 = 8;
led_data[i].level1 = 0;
led_data[i].duration1 = 4;
} else {
led_data[i].level0 = 1;
led_data[i].duration0 = 4;
led_data[i].level1 = 0;
led_data[i].duration1 = 8;
}
i++;
}
}
Serial.printf("RMT write %d %d %d\n",color[0],color[1],color[2]);
rmtWrite(rmt_send, led_data, BITS);
}
void led_blink(int r,int g,int b,int ms){
Serial.println("IRQ detach");
if(irqInit) detachInterrupt(TACT_LED_IO);
delay(5);
led_init();
led_set(r,g,b);
delay(ms);
led_set(0,0,0);
delay(5);
Serial.println("RMT De init");
rmtDeinit(rmt_send);
tact_init();
}
void led_init(void){
Serial.println("RMT Init");
if((rmt_send=rmtInit(TACT_LED_IO,true,RMT_MEM_64))==NULL)Serial.println("RMT init failed\n");
float realTick = rmtSetTick(rmt_send, 100);
}
void tact_init(){
pinMode(TACT_LED_IO, INPUT_PULLUP);
Serial.println("IRQ attach");
attachInterrupt(TACT_LED_IO,tactIsr,FALLING);
irqInit=1;
}
void setup(){
Serial.begin(115200);
while(!Serial);
delay(500);
Serial.println("System ready");
tact_init();
}
void loop(){
if(tactFlag){
Serial.println("tact handler");
while(!digitalRead(TACT_LED_IO))delay(1);
led_blink(127,10,75,50);
tactFlag=0;
}
} |
Thanks for reporting the issue! Issue solved with PR#6369. I tested the sketch you provided with the S2 and C3. Now it works fine. |
thank you for the update and fix ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Board
ESP32-C3 dev module
Device Description
DevKitC
Hardware Configuration
tact switch and assignable RGB LED on GPIO9
Version
latest master
IDE Name
arduino IDE
Operating System
windows 10
Flash frequency
80M
PSRAM enabled
no
Upload speed
CDC
Description
in this use case IO9 is shared between assignable LED and tact switch, the RMT driver should take over IO9 only when sending datas to the LED and tact switch interrupt should be attached otherwise. This concept is long proven on other SoCs but it does not work on esp32c3 yet, due to RMT driver bug.
Actually there is two bugs, the first is minor and can be fixed easily with a check, for now by commenting during the test, the second is of unknown cause yet, nothing shows up in the log.
1 rmtDeinit throws an error when used in TX only mode, i suspect stopping the (non exsting) RX channel is the cause.
2 once rmtDeinit has been called the RMT driver cannot be re-init or used anymore, any subsequent call to rmtInit will just lock everything up until hard reset or power cycle.
It seems something has not been cleared somewhere when RMT driver is deInit.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: