Introduction to RTOS Part 2 - Getting Started with FreeRTOS | Digi-Key Electronics

preview_player
Показать описание
FreeRTOS is a free and open source real-time operating system (RTOS) owned and maintained by Amazon.

In this video, we talk about how a task is created in FreeRTOS using the ESP32 and Arduino. A task in FreeRTOS is similar to a thread in other multi-threaded environments (e.g. POSIX). It is a unit of CPU utilization designed to accomplish some goal. For our purposes, we just want to create a new thread and toggle an LED.

The ESP32 that comes with many development boards (including the Adafruit Feather HUZZAH32 shown in the video) runs a modified version of FreeRTOS (if you are using the ESP32 package for Arduino or the Espressif SDK). Most importantly, the ESP32 version (named ESP-IDF) supports the dual-core processor on the ESP32. Tasks created with the regular xTaskCreate() can run on either core as chosen by the scheduler.

For demo purposes, we want to run all tasks on a single core. This will allow us to experiment with prioritization and shared resources later in this series. To do this on the ESP32, we use the xTaskCreatePinnedToCore() function instead and specify which core to use. If you are using vanilla FreeRTOS in your own build system, you will want to use xTaskCreate() instead.

Product Links:

Related Videos:


Related Project Links:

Related Articles:

Learn more:

Рекомендации по теме
Комментарии
Автор

Just finished a course in embedded systems using FreeRTOS. With these videos I can keep learning!

tehmudjinkhan
Автор

I love this series. Haven't had the need to use an RTOS yet, but I'm really enjoying learning about it.

juanperez
Автор

I can't believe this information is provided for free. Thank you so much for making this knowledge accessible.

darrennewell
Автор

finally YouTube algorithm that is on point! Thanks Shawn!

JeromeDemers
Автор

A year later - but really appreciating this series.

I need to build a custom motor driver to control 4 full h-bridge drivers chips with single on/off pulses as short as 5uS, in addition to also receiving output from an absolute encoder to get rotor angle information, throttle input, etc. to calculate and drive those 4 other stator control tasks. A general purpose OS is not going to cut it.

Now if this supply chain issue can get resolved so I can actually purchase some of these demo boards to work with...

hallkbrdz
Автор

This gives a greater understanding of the language instead of coping & pasting then just changing the time sequence! Thanks for the tutorial because I learn every time..

MrWATCHthisWAY
Автор

Right after i get courses on RTAI Linux, it is pretty the same concept but you made it so much easier and fun !

rochdimaria
Автор

Thank you for these FreeRTOS videos. They're super helpful for me. I'm looking forward to future videos!

AlwinArrasyid
Автор

This series is great! Your teaching style in inspiring. Such depth of knowledge and attention to detail. Hopefully Digikey will keep producing material with Shawn Hymel 🙏

darkrasen
Автор

I am using archlinux for this, I had to do several step to get everything working:
- install pyserial (python -m pip install pyserial)
- give permissions to dev (sudo usermod -a -G uucp <username> && sudo usermod -a -G tty <username>
- logout -> login
- make sure the usb cable has data wires and not only power
- hold the boot button when I upload

Haxory
Автор

No fluff and quickly moving through it in good detail thanks.

mranthony
Автор

Not gonna lie this series seems to be great!

sirsundays
Автор

I struggled a bit to understand why #if, BaseType_t, and few other terms used. After few background search I found out:

1. # - these are pre-processor directives. i.e., processed before actual compilation. Thus, #if statement already decides what's the value of app_cpu even before actual compilation.

2. BaseType_t is typedef (keyword to create new type alia) in header file, and it was int.


This is what I understood, do point out if I have mistaken these terms.

adityasreeram.k.s
Автор

Amazing! Clear, and very information dense, but not overwhelming.

Quarky_
Автор

my solution to the challenge - (written in esp-idf, on vs code)
hope it helps.
i have worked with freertos before but a long time back, so needed to start from basics again as i was not using it in day to day basis until now, and now i will which i why here i am again to study it . (will read docs later)

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "esp_random.h"

#define LED_GPIO 2
#define PREV_LEVEL 0

volatile int DELAY = 500;
volatile int count = 0;

QueueHandle_t delayQueue;

gpio_config_t my_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = (1 << LED_GPIO)
};

void define_gpio()
{

}

static void change_delay_time(void *pvParam)
{
int newDelay;
while (1)
{
newDelay = esp_random() % 501;
xQueueSend(delayQueue, &newDelay, portMAX_DELAY);
vTaskDelay(5000 / portTICK_PERIOD_MS); // Delay to simulate periodic change
}
}

static void toggle_led(void *pvParam)
{
int led_level = PREV_LEVEL;
int receivedDelay;
while (1)
{
if (xQueueReceive(delayQueue, &receivedDelay, 0) == pdPASS)
{
DELAY = receivedDelay;
printf("CURRENT DELAY RATE - %d\n", DELAY);
}
led_level = !led_level;
gpio_set_level(LED_GPIO, led_level);
vTaskDelay(DELAY / portTICK_PERIOD_MS);
}
}

void my_task_start(void)
{
delayQueue = xQueueCreate(1, sizeof(int));
if (delayQueue == NULL)
{
printf("Failed to create queue.\n");
return;
}
xTaskCreatePinnedToCore(&toggle_led, "MY TASK", 2048, NULL, 10, NULL, 1);
xTaskCreatePinnedToCore(&change_delay_time, "DELAY TIME CHANGING TASK", 1024, NULL, 9, NULL, 1);
}

void app_main(void)
{
define_gpio();
my_task_start();
}


this solution has 2 tasks, one that sets the delay, other that toggles the led on this delay.
it uses queue to communicate between tasks, i tried many times before finalizing this solution, hope this helps.

kavishladha
Автор

These Videos are great! Looking forward to the next one (hopefully very soon).

louis
Автор

Thanks 👍👍Brother, for help me write my first rtos program

all-about-automation
Автор

Thank you this makes start using FreeRtos and ESP32 much simpler!

antoine_marchal
Автор

This series looks great! Looking forward for the next videos and next series!

manuel_youtube_ttt
Автор

Please put the link in the description for the webpage @2:53
Also add in the description the JSON link to add in the Preference of Arduino IDE.

DeLaCruzer