I am encountering a very strange error using freeRTOS on an Arduino Mega2560:
In the setup block I can create an instance of my class:
MyClass* myClass = new MyClass(char a, char b, new Vector(42)); // new Vector(42) creates a new vector and pushes 42 in as first item
Using a print() method in this class, I get a legimit output on the console, showing me all the chars and values in the vector.
Using the exact same line inside a task, causes the object not to be created properly. It seems like the fields are empty or there is something entirely wrong (like strange memory errors) with the instance. Printing it again results in an empty line (program doesn’t crash) while printig a globally created instance gives the correct result.
Is there any trap in freeRTOS concerning the creation of new instances of an object inside a task? Below is the code for the task creation, increasing the task stack size doesn’t help. For debug reasons this the only task running at the moment.
xTaskCreate(displayTask, "DisplayTask", configMINIMAL_STACK_SIZE + 300, NULL, tskIDLE_PRIORITY + 1, NULL);