Closed wegunterjr closed 3 years ago
What does the task do, and what kind of blinking?
Is it the backlight that's blinking? Or the image on the screen?
Can you share your changes to the code?
This says that all GUI work needs to be done from the same core: https://github.com/lvgl/lv_port_esp32/blob/master/main/main.c#L64 (my example code uses Core 1 for gui_thread
)
it seems like the backlight is blinking with no image on the screen. I am trying to do this outside of the gui task/core.
I tried a couple of things, this is one of them:
void simple_task(void *arg)
{
printf("in the simple task.\n");
}
// xTaskCreatePinnedToCore(simple_task,
// "simple_task",
// 2048,
// NULL,
// 5,
// NULL,
// 0);
// xTaskCreate(simple_task,
// "simple_task",
// 2048,
// NULL,
// 5,
// NULL);
OK I see, then I expect your problem is this (refer to the FreeRTOS docs):
Tasks are normally implemented as an infinite loop, and must never attempt to return or exit from their implementing function. Tasks can however delete themselves.
If you run idf.py monitor
I expect you'll see the crash in the log, something like:
E (1234) FreeRTOS: FreeRTOS Task "simple_task" should not return, Aborting now!
abort() was called at PC 0x4008a12f on core 1
0x4008a12f: vPortTaskWrapper at /home/brian/sources/esp/esp-idf/components/freertos/xtensa/port.c:147
Backtrace:0x40085b3f:0x3ffd68d0 0x40086029:0x3ffd68f0 0x4008cc7e:0x3ffd6910 0x4008a12f:0x3ffd6980
0x40085b3f: panic_abort at /home/brian/sources/esp/esp-idf/components/esp_system/panic.c:330
0x40086029: esp_system_abort at /home/brian/sources/esp/esp-idf/components/esp_system/system_api.c:68
0x4008cc7e: abort at /home/brian/sources/esp/esp-idf/components/newlib/abort.c:46
0x4008a12f: vPortTaskWrapper at /home/brian/sources/esp/esp-idf/components/freertos/xtensa/port.c:147
For me, this works fine (just put an infinite loop in your simple task, add a delay to avoid using 100% CPU)
diff --git a/main/main.c b/main/main.c
index 560bc35..0ae6488 100644
--- a/main/main.c
+++ b/main/main.c
@@ -242,6 +242,15 @@ static void set_internal_5v_bus(const axp192_t *axp, bool on)
}
}
+void simple_task(void *arg)
+{
+ printf("Simple task\n");
+
+ for ( ; ; ) {
+ vTaskDelay(portMAX_DELAY);
+ }
+}
+
void app_main(void)
{
printf("Hello world!\n");
@@ -522,6 +531,8 @@ void app_main(void)
printf("Running...\n");
fflush(stdout);
+ xTaskCreate(simple_task, "simple_task", 2048, NULL, 5, NULL);
+
for ( ; ; ) {
vTaskDelay(portMAX_DELAY);
}
doh! That was it! Thanks!
I tried adding another task to the other core, but having issues with the screen just blinking.
Any suggestions?