The problem of data transfer between the cores on ESP-Wroom-32.

Hello. In this code it is not possible to print correctly the data on each task. I can not understand the reason. The output of the program is below. How do I get the HELLO_WORLD string in each of the tasks in the output? Using the parameter transfer. Thank you. ~~~

include <string.h>

include “freertos/FreeRTOS.h”

include “freertos/task.h”

include “freertos/event_groups.h”

include “esp_system.h”

include “espeventloop.h”

include “esp_log.h”

include “nvs_flash.h”

const sizet stacksize = 4096; static void task1(void *pvParameters) { ESP_LOGE(“TASK”, “TASK CORE_1: %s”, (char *)pvParameters); vTaskDelete(NULL); } static void taskmain(void *pvParameters) { char *data = (char *)pvParameters; while(1) { ESPLOGI(“TASK”, “TASK CORE0: %s”, data); vTaskDelay(1000 / portTICKRATEMS); xTaskCreatePinnedToCore(&task1, “task1”, stacksize, (void*)&data, 2, NULL, 1); } vTaskDelete(NULL); } void appmain() { char data[12] = “HELLOWORLD”; xTaskCreatePinnedToCore(&taskmain, “taskmain”, stack_size, (void*)&data, 1, NULL, 0); } ~~~ OUTPUT: ~~~ E (264246) TASK: TASK CORE1: ��? I (265246) TASK: TASK CORE0: E (265246) TASK: TASK CORE1: ��? I (266246) TASK: TASK CORE0: E (266246) TASK: TASK CORE1: ��? I (267246) TASK: TASK CORE0: E (267246) TASK: TASK CORE1: ��? I (268246) TASK: TASK CORE0: E (268246) TASK: TASK CORE1: ��? I (269246) TASK: TASK CORE0: E (269246) TASK: TASK CORE1: ��? I (270246) TASK: TASK CORE0: E (270246) TASK: TASK CORE_1: ��? ~~~

The problem of data transfer between the cores on ESP-Wroom-32.

Probably because appmain is left and the string is a stack variable at least concerning taskmain. Be careful with the lifetime of data given by pvParameters. Why not using a task local string ? Provided that ESP_LOGI irtself is thread-safe of course 😉

The problem of data transfer between the cores on ESP-Wroom-32.

Probably because appmain is left and the string is a stack variable at least concerning taskmain. Be careful with the lifetime of data given by pvParameters.