feilipu / Arduino_FreeRTOS_Library

A FreeRTOS Library for all Arduino ATmega Devices (Uno R3, Leonardo, Mega, etc).
MIT License
848 stars 204 forks source link

Issue with delay(); #132

Closed WildSwan closed 8 months ago

WildSwan commented 8 months ago

Describe the issue delay() function stops the code from continuing.

Sample code:

=================================================================
#include <Arduino_FreeRTOS.h>

void setup() {

  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);

  delay(1000);

  Serial.println("Setup starts.");    // This wont execute anymore.

}

void loop()
{
  // Empty. Things are done in Tasks.
}
=================================================================

Expected behavior "Setup starts." should be displayed on the serial monitor.

Desktop (please complete the following information):

feilipu commented 8 months ago

delay() relies on the scheduler to operate. The scheduler is only initialised on return from the setup() function. So your example code can never work.

Do not use delay within the setup and you will be fine.