FreeRTOS Tutorial-1
Introduction
To use FreeRTOS, we will use a special version that runs in simulation mode in Windows. The simulator is included in the source files and is included in the .exe file that is created during compilation.
We will use Eclipse and the MinGW compiler that is already installed on the lab machines.
The objective of this tutorial is to explore the FreeRTOS code, configure the system and create simple tasks.
Eclipse Configuration
To get started, run Eclipse for C ++ Developers . Download the start code , but do not unzip the file.
In Eclipse, go to File> Import> General> Existing Projects into Workspace . Press Next and in the next window select the Select archive file option . Tap Browse … and navigate to where the start code was downloaded. Tap Finish .
You should be able to compile the project into Release. To make sure you can properly start the project, add in the function main()
before the loop for, the line printf("Hello World!");
then compile again.
To start the simulator, using the Windows command prompt ( Start> cmd ), navigate to where the .exe file is located (in the directory containing your workspace, for example, C:\Users\lapointe\cpp-workspace\EmptyFreeRTOSApp\Release
). When you are in the right directory, launch your .exe . It should show Hello World! .
You now have a functional source code and configuration of the FreeRTOS which can be run in simulation mode. Remember the steps to follow for the lab 3. The fllowing figure shows an overview of the code structures which includes FreeRTOS source code, windows port and configuration file.
Exploration of FreeRTOS
Referring to the code provided and FreeRTOS book, answer the following questions. You will have to give them to your instructor before the beginning of the lab 3. The answers will be counted in the laboratory 3.
- What are the possible statuses of a task?
- In the present configuration, is the OS scheduling cooperative or preemptive?
- What is the size of the FreeRTOS heap?
- Are dynamic memory allocation error handling supported?
- What implementation of
malloc()
andfree()
is used? check heap_* file and explain your answer. - What is the Task Control Block for ? How is it defined and where? What information does it contain?
- Explain how xTaskCreate works.
Creation of some tasks.
- Create two tasks. One will display “Hello” and the other “World”. Observe the behavior of the system. What do you notice?
- Implement examples 1-3 of Chapter 3 of Mastering the FreeRTOS Real Time Kernel
Note: You must use fflush(stdout) after using printf().