Arduino Multitasking Stackchange Beta 1.1 July 8 2019
CoopOS with Stackframes
You never thought that multitasking can be so easy:
This is a simple and fast approach to multitasking.
More than 50 pages documentation !
• Very easy to use even for beginners - nothing else comes close
• Usable for professionals
• Reliable timings
• Tasks have priorities and own stacks
• Full documentation
• Compatible with all Arduino Libraries
• In the simplified form only one file to include
• Could be combined with RTOS's as Idle-Task
• Easy to port to other processors • Valuable tools for development and tests• 25000 (40 µs) TaskSwitches per second on Arduino-UNO / -NANO are possible
• Breakpoints in source or with Debug-Button (stop/resume) or serial input
• Breakpoint may show last 20 scheduled tasks with timestamp
• Watchdog-Interrupt to test Task Switching
• Up to 200000 Interrupts/s !
Extract the CoopOS_Stack_MT_Nano.zip file with all features to your Arduino-sketch directory.
But it is highly **recommended** to read the documentation and experiment at first with the Demo files.
This is the simple Demo0 - here we use Cooperative Multitasking with stack-change!
//// CoopOS_Stack_MT - Demo (C) 2019 Helmut Weber //// Demo0 #include "TaskSwitchDemo.h" #define LED 13 void Task1() { // Blink LED while(1) { // <<< You will find these while(1) loops in all RTOS's examples digitalWrite(LED,HIGH); // if you call this in a normal Arduino sketch nothing else will run ! Delay(50000); digitalWrite(LED,LOW); Delay(50000); // microseconds } } void Task2() { // Write to Serial Line while(1) { // Another infinit loop ! Serial.println("Hello World"); Delay(1000000); } } void setup() { Serial.begin(500000); StackInit(); // Init the stacks for all tasks TaskInit("T1", Task1, 90, 100, 0, READY); // define 2 tasks for multitasking: TaskInit("T2", Task2, 90, 100, 0, READY); StartMultiTasking(); // start the system: } void loop() { // loop is never called //// this is never called !!! Serial.println("Hoops? How did you come to this line ???"); }
//// CoopOS_Stack_MT - Demo (C) 2019 Helmut Weber //// Demo0
With the final program "TheProgram" it is possible to proof with the WDT
that no task needs more than 100 µs !
That means: highly deterministic !