Page 1 of 1

Decoder for remote control PPM signal

Posted: Mon Dec 04, 2023 7:09 pm
by Johannes_Hellb
Hello, I am using an ESP32 Dev. Enclosed is a small but fast decoder for decoding the PPM radio signal. It works very well, but with a delay below 3 ms it gives the following error message:
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Can anyone help me ?
I am using the Arduino IDE 2.2.1 Best regards
John
//06 Nur bei delay(4)
// ESP32 2.0.18
// Radio control Flysky FS -I
// PPM signal from Radio control

volatile uint64_t timer_lesen = 0;
volatile int flag_fa = 0;
volatile int ch_nr = 0;
volatile int ch[12];

hw_timer_t* timer1 = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;

void ARDUINO_ISR_ATTR onTimer() { // Interrupt on pin 13

portENTER_CRITICAL_ISR(&timerMux);

if (flag_fa == 0) {
timerStart(timer1);
ch_nr++;
flag_fa = 1;
}

else {
timerStop(timer1);
timer_lesen = timerRead(timer1);
timerWrite(timer1, 0);

if (timer_lesen > 10000) ch_nr = 0; // Synchronisation of the PPM signal
ch[ch_nr] = timer_lesen; // Data from Synchronisation of the PPM signal
// ch_nr = Channel number 1 to 6
flag_fa = 0;
}
portEXIT_CRITICAL_ISR(&timerMux);
}

void setup() {
Serial.begin(115200);

// Decoder PPM Pin13
pinMode(13, INPUT_PULLUP); // PPM Signal on PIN 13
timer1 = timerBegin(0, 30, true);
attachInterrupt(digitalPinToInterrupt(13), &onTimer, CHANGE);
timerWrite(timer1, 0);
}

void loop() {
portENTER_CRITICAL(&timerMux);

Serial.print(ch[0]);
Serial.print(" ");

Serial.print(ch[1]);
Serial.print(" ");

Serial.print(ch[2]);
Serial.print(" ");

Serial.println(ch[3]);
Serial.println(" ");

portEXIT_CRITICAL(&timerMux);

delay(3); // Error delay under 3 ms !!
}[/code]

Re: Decoder for remote control PPM signal

Posted: Tue Dec 05, 2023 2:17 am
by ESP_Sprite
That error means you're spending too long in either an ISR or a critical section. This means that the interrupts needed for general ESP32 housekeeping can't fire, and that gives that error.

If anything, you're doing serial output (which is slow) in a critical section (which are supposed to be only for fast things, like setting a variable). In this particular case, it looks like you're protecting the ch[] array, so I'd suggest restricting the bits where you have a critical section to only the line where you set or read this. In the ISR, this means only making 'ch[ch_nr] = timer_lesen' critical, and in the main function, you probably want to copy the ch[] array to another (temp) array in a critical section, then print the temp array outside of that critical section.

Re: Decoder for remote control PPM signal

Posted: Tue Dec 05, 2023 6:42 pm
by Johannes_Hellb
Thanks for the information, the programme is now running...