- C:\Users\Real\.platformio\packages\framework-espidf\components\freertos\queue.c:1448 (xQueueGenericReceive)- assert failed!
- abort() was called at PC 0x40085805 on core 1
I don't understand what I'm doing wrong because when I copy this code and compile/flash it from Arduino IDE (making the proper adjustments to the usual Arduino format) it runs fine without crashing.Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled
I'm using PlatformIO in Visual Studio Code and the IDF version is 4.0. The code is the following:
- #include <stdio.h>
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "freertos/semphr.h"
- #include "esp_system.h"
- #include "sdkconfig.h"
- SemaphoreHandle_t mux;
- char sharedBuf[20];
- void task1(void *pv)
- {
- char task1Msg[] = "01234";
- for(;;) {
- if(xSemaphoreTake(mux, portMAX_DELAY) == pdTRUE) {
- for (int i = 0; i < 5; i++) {
- sharedBuf[i] = task1Msg[i];
- vTaskDelay(100 / portTICK_PERIOD_MS);
- }
- printf("Task1 msg: %s\n", sharedBuf);
- xSemaphoreGive(mux);
- }
- vTaskDelay(100);
- }
- vTaskDelete( NULL );
- }
- void task2(void *pv)
- {
- char task2Msg[] = "56789";
- for(;;) {
- if(xSemaphoreTake(mux, portMAX_DELAY) == pdTRUE) {
- for (int i = 0; i < 5; i++) {
- sharedBuf[i] = task2Msg[i];
- vTaskDelay(100);
- }
- printf("Task2 msg: %s\n", sharedBuf);
- xSemaphoreGive(mux);
- }
- vTaskDelay(100);
- }
- vTaskDelete( NULL );
- }
- void app_main()
- {
- xTaskCreate(task1, "Task1", 4000, NULL, tskIDLE_PRIORITY, NULL);
- xTaskCreate(task2, "Task2", 4000, NULL, tskIDLE_PRIORITY, NULL);
- mux = xSemaphoreCreateMutex();
- vTaskStartScheduler();
- while (1) {
- }
- }