Task date doesn't update

Dear all,
I am an electronic engineer. I wanna create a task with vstudiocode to update the counter in the label of WT32-SC01 I put a taskdelay of 1 second but the task starts one time while If i put 10 secondi the task start and it updates the label. This is the code.
int counter = 0;

int i = 1;

const char *counter_[2];

counter_[1]='\0';

//counter_[2]=0;

while (1)

{

   vTaskDelay(pdMS_TO_TICKS(10000));

    itoa(counter,counter_,10);

   

    ESP_LOGI(TAG,"%d",counter);

    lv_label_set_text(label_880e, counter_);

    counter++;

    i++;

    //vTaskDelay(pdMS_TO_TICKS(2000));

}

vTaskDelete(NULL);

}

xTaskCreate(counter, “counter”, 4*1024, NULL, 0, NULL);

How can I resolve?

I’m not sure this caused the problem, but pay attention to this.

static mutex_t lvgl_mutex;
type mutex_t doesn’t exist in my project. How can I do?
Let me know
I’ll very appreciate your respond.
Thanks in advance
Francesco Pugliese

It’s just an example, see how you can do it FreeRTOS.

This is the code, but it doesn’t work . The label doesn’t update. Why?
void Task (void* arg){
int counter = 0;

int i = 1;

const char *counter_[2];

counter_[1]='\0';

//counter_[2]=0;

while (1)

{

    SemaphoreHandle_t xSemaphore;

    xSemaphore = xSemaphoreCreateMutex();

   vTaskDelay(pdMS_TO_TICKS(1000));

   if( xSemaphore != NULL )

{

    itoa(counter,counter_,10);

   

    ESP_LOGI(TAG,"%d",counter);

    //lv_label_set_text(label_880e, counter_);

     lv_label_set_text_fmt(label_880e,"%c :",counter_);

    printf("ciaaaaaaaaaaaaaaaaoOOOOOOOOOOO");

   

    counter++;

    i++;

    vSemaphoreDelete( xSemaphore );

    //vTaskDelay(pdMS_TO_TICKS(2000));

}

}

vTaskDelete(NULL);

}

The semaphore must be “taken” before the critical section and “given” after that.

See This page describes the xSemaphoreTake() FreeRTOS API function which is part of the RTOS semaphore API source code function set.