Decoder for remote control PPM signal

Johannes_Hellb
Posts: 2
Joined: Sun Dec 03, 2023 6:23 pm

Decoder for remote control PPM signal

Postby Johannes_Hellb » Mon Dec 04, 2023 7:09 pm

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]

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

Re: Decoder for remote control PPM signal

Postby ESP_Sprite » Tue Dec 05, 2023 2:17 am

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.

Johannes_Hellb
Posts: 2
Joined: Sun Dec 03, 2023 6:23 pm

Re: Decoder for remote control PPM signal

Postby Johannes_Hellb » Tue Dec 05, 2023 6:42 pm

Thanks for the information, the programme is now running...

Who is online

Users browsing this forum: Baidu [Spider] and 101 guests