-
Notifications
You must be signed in to change notification settings - Fork 171
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
code in the examples can crash on ESP32 #225
Comments
Hi, Tried this one but looks like the code does not compile due to missing displayUpdateTaskHandle, not sure of what I need to do to get this working. would you mind help me to try ? ok, self answer, declaration of
|
Whoops, sorry about that. You have to declare a task handle.
I updated my example above. |
sorry, it was not the source of the error, you declared it twice now, it was related to declaration of Working code is here (was also missing a parenthesis in if condition of fixed code below, thanks for sharing #define CORE_1 1
TaskHandle_t displayUpdateTaskHandle = NULL;
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR display_updater(){
{
portENTER_CRITICAL_ISR(&timerMux);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
//notify task to unblock it
vTaskNotifyGiveFromISR(displayUpdateTaskHandle, &xHigherPriorityTaskWoken );
//display task will be unblocked
if(xHigherPriorityTaskWoken){
//force context switch
portYIELD_FROM_ISR( );
}
portEXIT_CRITICAL_ISR(&timerMux);
}
void displayUpdateTask(void *)
{
for(;;){
//block here untill timer ISR unblocks task
if (ulTaskNotifyTake( pdTRUE, portMAX_DELAY)){
display.display();
}
}
}
void setup()
{
Serial.begin(112500);
display.begin(16);
/* we create a new task here */
xTaskCreatePinnedToCore(
displayUpdateTask, /* where display() actually runs. */
"displayUpdateTask", /* name of task. */
2048, /* Stack size of task */
NULL, /* parameter of the task */
3, /* Highest priority so it is immediately launched on context switch after the ISR */
&displayUpdateTaskHandle, /* Task handle to use for task notification */
CORE_1);
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &display_updater, true);
timerAlarmWrite(timer, 2000, true);
timerAlarmEnable(timer);
} |
Sorry about that, that's what I get from trying write code from my phone |
I'am not getting this to work... i have problems with the old way of the ISR and display.display... For me it looks like it's not getting past the timer part in the setup. Owww BTW void IRAM_ATTR display_updater(){ There is a { too much there. |
Good catch, I edited my example |
I hope you can help me with this problem... Sadly using this code gives me a panic much quicker than before. Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. When i do it the old fashioned way i can handle buttons but not other things like a wifimanager. It does crash always at the display.display part. Hardware used: ESP Decoding results: PC: 0x4008c044: vTaskNotifyGiveFromISR at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 5018 Decoding stack results |
I've not had issues with button interrupts and the code above. Maybe the code doesn't handle being interrupted? You could also play around in PxMatrix.h and change the SPI clock rates, Your screen is much bigger than the one I was using, thus takes much longer to fill. |
Using pxMatrix 1.8.2 on an ESP32, as part of a larger program.
I was building an application that used plenty of other sensors on different cores and thread. Effectively I was getting core crashing when this ISR callback was being called. Then I took a look at display.display() and saw that it was a reasonably large block of code being called from an ISR.
surely doing something like this would be safer?
The examples run fine on their own, problems may arise when others may try to use them as the basis for a more complex program.
Edit:added taskhandle declaration.
Edit2: removed extraneous bracket in display_updater()
The text was updated successfully, but these errors were encountered: