#244

Опубликовано: 20 Май 2022
на канале: Ralph S Bacon
13,184
860

A real-time operating system for the humble UNO (and Mega2560 etc)
► JLCPCB Only $2 for PCB Prototype any colour https://jlcpcb.com/cyt

Full details including sketches and much more in my GitHub:
https://github.com/RalphBacon/244-RTO...

So can we run an operating system (task scheduler) on an Arduino Uno in a meaningful way? By "meaningful way" I mean more than just flashing a couple of LEDs. Stay tuned, you may be pleasantly surprised.

The video demonstrates a simple, two-LED example, before doing something a bit more "meaningful" (something I'm actually doing in a project right now).

► You can now support me by buying me a coffee!
https://buymeacoffee.com/ralphbacon

The Arduino loop()

FreeRTOS can optionally include the standard Arduino loop as part of the RTOS **idle task**. This task only runs when no other task is waiting for processor time, which might mean the loop will never run.

Ideally, include the *void loop()* function, but leave it empty.

To emulate a loop function of your own, create a separate task to run something called myLoop which looks just like the standard loop but over which you have total control.
```
void myLoop() {
for (;;) {
// Put all your code for the loop here - runs repeatedly
}
}
```
Schedule the loop in the usual way (see the video for more details) in the setup function:
```
xTaskCreate(
myLoop, // the function to run
"Loop", // Friendly name
256, // Stack size
NULL, // no parameters for loop task
1, // Priority
NULL ); // handle
```
Then you have the same setup as an ESP32. I tend to use the loop() function (myLoop() here) as a sort of master control.

Resources

CoolTerm serial monitor (freeware):
https://freeware.the-meiers.org/

Arduino RTOS library by Phillip Stevens:
https://github.com/feilipu/Arduino_Fr...

Essential reading about Arduino RTOS by Phillip Stevens:
https://feilipu.me/2015/11/24/arduino...

Running RTOS on an Arduino Nano Every (ATMega 4809)
https://tomalmy.com/freertos-on-ardui...

► List of all my videos
(Special thanks to Michael Kurt Vogel for compiling this)
http://bit.ly/YouTubeVideoList-RalphB...

► If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite (and other μControllers) journey

My channel, GitHub and blog are here:
------------------------------------------------------------------
•    / ralphbacon  
• https://ralphbacon.blog
• https://github.com/RalphBacon
• https://buymeacoffee.com/ralphbacon
------------------------------------------------------------------


Смотрите видео #244 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Ralph S Bacon 20 Май 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 13,18 раз и оно понравилось 86 людям.