freeRTOS - problema temporizzazione blink

Allora, ho fatto qualche prova.

il tuo codice Guglielmo non compila

In function 'void setup()':
sketch_jun14b:22: error: 'xTaskCreateStatic' was not declared in this scope
    xTaskCreateStatic(MyTask1, "Task1", 192, NULL, 1, uxStackBuffer_T1, &xTaskBuffer_T1);

e non sono riuscito a sistemarlo.

Se invece faccio un ibrido tra i due allora funziona:

questo

#include <Arduino_FreeRTOS.h>

void TaskBlink(void *pvParameters);

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
  xTaskCreate(TaskBlink, (const portCHAR *)"Blink", 192, NULL, 1, NULL);

}

void loop() {
  // put your main code here, to run repeatedly:

}

void TaskBlink(void *pvParameters)  // This is a task.
{
  for (;;) // A Task shall never return or exit.
  {

    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    vTaskDelay(20 / portTICK_PERIOD_MS);
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    vTaskDelay(2000 / portTICK_PERIOD_MS);
  }
}

e anche questo

#include <Arduino_FreeRTOS.h>

void TaskBlink(void *pvParameters);

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
  xTaskCreate(TaskBlink, (const portCHAR *)"Blink", 128, NULL, 2, NULL);

}

void loop() {
  // put your main code here, to run repeatedly:

}

void TaskBlink(void *pvParameters)  // This is a task.
{

  TickType_t xLastWakeTime;
  const TickType_t xPeriod = 2000 / portTICK_PERIOD_MS;
  xLastWakeTime = xTaskGetTickCount();
  for (;;) // A Task shall never return or exit.
  {
    vTaskDelayUntil( &xLastWakeTime, xPeriod );
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    vTaskDelay( 20 / portTICK_PERIOD_MS ); // wait for 20millisecond
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  }
}

nel mio codice il problema principale sembra essere pdMS_TO_TICKS() ::slight_smile:

p.s. nei reference in pdf, quelli che sto leggendo, portTICK_PERIOD_MS non viene neanche menzionato :stuck_out_tongue_closed_eyes: