Geese
Written in front
Previous article I provide you can run directly, if you have tested friends, you want Frertos to run, you can add Freertos to your own project without modifying many code and configuration information, you can add Freertos to your own project and succeed start running.
From this article, you will tell the code in Freertos. In order to take care of most of our friends, it is still simple and found.
The contents of "freertosconfig.h" configuration in Freertos increases with the increase in version (function), that is, as the system function increases, the corresponding configuration information is also increased. But the system is compatible with the system itself in order to be compatible with the previous code.
For example: configuse_queue_sets is the options defined in "freertosconfig.h", if the user is not defined, there is a definition in "freertos.h".
#ifndefconfiguse_queue_sets
# DefineConfiguse_Queue_Sets0
#ENDIF
When you start designing the Freertos system, engineers will definitely think that try to reduce the development difficulty of developers. When we begin a transplantation of Freertos, most of the configurations in "freertosconfig.h" choose to default. Only later familiar, the development needs to use more functions, the configuration inside must be ripe.
Friends who are not disgusted in English suggest that the content of the official website, after all, the official website is the most authoritative.
Official website address:
http://www.freertos.org/a00110.html
From the information provided by the official website, you can see "freertosconfig.h" to divide the configuration information into a 10 category, but many configuration information we can choose not (or not defined).
The technical article section of the technical article in the WeChat public account is not too long. This article is for beginners, first tells the general configuration.
II
General configuration
This chapter is also a basic configuration, anyway, it is a more important configuration that we define, but also a more important configuration.
Tip: The belt (*) is relatively understood, or more important.
Freertosconfig.h profile involves many nouns on the system, and many beginners may not be easy to understand. For example: signal volume, message queue, mutex, event group ... ·····
But don't worry, there is a probilization first, and I will have a targeted focus later.
1.configuse_pree mption
Scheduling mode configuration
Configured to 0: cooperative scheduling, implantation wheel flow execution;
Configured to 1: Zuzhang schedule, that is, the priority task is preemptive;
Since we ask for real-time response, it is configured to 1, use the preemptive scheduling mode. Otherwise, it does not play the role of the real-time operating system.
2.configcpu_clock_hz
The CPU clock is our main frequency. Note: The unit is Hz.
Such as: STM32F407 is 168m:
#define configcpu_clock_hz (168000000)
3.configTick_Rate_Hz
The system tick, that is, the number of times the system is tick per second, it can be said that the system's heartbeat, but needs to be separated from the main frequency zone. The value of the system tick is based on the CPU frequency. The higher the frequency, the higher the value, and the value is relatively large, and is generally between 100 and 1000.
Simple example: The system tick determines vtaskdelay.
for example:
#define configTick_Rate_Hz (1000)
but:
VtaskDelay (1000) indicates delay 1s.
4.configmax_priorities
System maximum priority value
We create tasks is that the priority value of the configuration cannot exceed this maximum.
Xtaskcreate (Vapptask1, "Task1", Task1_stack_size, null, task1_priority, null;
hint:
a. System priority and interrupt priority principle Similar, high priority will grab a low priority front, but require a distinction system and interrupt priority application scenario.
The larger the priority value in Freertos, the higher the priority. The UCOS is the opposite.
5.configminimal_stack_size
Minimum stack value
In the system, generally used in some system tasks such as idle, timing, of course, we can use this defined stack value in some places.
Note the unit of value, usually 4 bytes in ARM.
6.configtotal_heap_size
A total of a total of the system (stack)
We need to define this value as needed. It can't be defined, too small memory is easy to overflow; it can't be defined too big, some chip RAM itself is not large (some only a few k), if we don't know too much global variable, or allocate other stack space .
7.configmax_task_name_len
Task name maximum length
That is, create a string length of the task definition task name.
Xtaskcreate (Vapptask1, "Task1", Task1_stack_size, null, task1_priority, null;
Tip: The end value '\ 0' is also included.
8.configuse_16_bit_ticks
Whether to use 16-bit titaning count value
Configured to 0: Use a 32-bit tick count value, generally configured in a 32-bit processor;
Configured to 1: Use a 16-bit tick count value, a general 8-bit or 16-bit processor configured to 1.
9.configidle_should_yield
Do you let the idle task "give up" to preempt
That is, during the task of performing the same priority as the idle task, whether the idle task has a chance to preempt.
Configured to 0: Do not give up the preemption;
Configured to 1: Abandon the preemption;
10.configuse_mutexes
Whether to use a mutex
Configured to 0: Not used
Configured to 1: use
Tip: The mutex is also called the quantity of mutual exclusive, that is, "lock" "lock". Its role is to achieve exclusive processing of shared resources between multitasking. Simply put, a resource only allows only one task to be processed at some point, and other tasks are allowed to process the resource after processing.
For example: A task is high, the B task is priority; the AB task uses a serial port to send instruction data, (ie, each time you must send it, you can't send it to half).
When the B task is sending data, the A task is in the ready state (to interrupt B task). Then the B task needs to use a mutex (locking, occupying the resource), etc., the serial port (unlock, release the resource). Once the resource is released, the A task can use the serial port (resource).
11.configuse_recursive_mutexes
Whether to use recursive mutually exclusive lock
Configured to 0: Not used
Configured to 1: use
13.configqueue_registry_size (*)
Adding (or registered) queue number
This configuration information is not easy to translate, it mainly combines the two functions of VQueueAddtryGistry and VqueueunRegisterQueue.
Directly on the function interface:
Void Vqueueraddtoregistry (QueueHandle_t Xqueue, Const Char * Pcqueueename);
Void vqueueunregisterQueue (QueueHandle_t xqueue);
From the function interface, you can know that a function is the name of the registration (already created) queue; a function is the name of the logout queue;
In fact, the main purpose is to name the (already created) queue, which is convenient for debugging.
Tip: Many beginners understand "the maximum number of you can create queues", this configuration parameter is completely different.
14.configuse_queue_sets (*)
Whether to use a message queue "set" function
Configured to 0: Not used
Configured to 1: use
This configuration information is also relatively difficult to understand.
Tip: Many of the Internet is explained as: enable / disable message queues. This understanding is too general, with the information related to the message queue configuration, I personally feel incorrect.
15.configuse_time_slicing
Whether to use a time piece to schedule
This parameter is used in conjunction with the first configuration parameters of ConfigUse_Pree Mption.
This configuration parameter is added in the new version of the back, it seems that there is no such configuration parameter before the V7 version. So, the default is not by default in the freertosconfig.h configuration file, but defined in Freertos.h.
#ifndef configuse_time_slicing
#define configuse_time_slicing 1
#ENDIF
III
Essence
The effect of the previously launched e-book version is good. Therefore, adhere to the PDF version of the Frertos series tutorial for everyone.
[Tip: WeChat public number does not support external links]
Freeertos series tutorial PDF e-book download address:
http://pan.baidu.com/s/1nuhff5n
Many of the online tutorials do not have a matching Demo routine, I hope that this series of tutorials telling the Demo routine can make everyone easier to learn.
Freertos_stm32f0_demo download address:
http://pan.baidu.com/s/1qybmfy0
Freertos_stm32f1_demo download address:
http://pan.baidu.com/s/1jhdhrpc
Freeertos_stm32f2_demo download address:
http://pan.baidu.com/s/1mi3eidq
Freeertos_stm32f3_demo download address:
http://pan.baidu.com/s/1kuzu5g7
Freeertos_stm32f4_demo download address:
http://pan.baidu.com/s/1bpllz7x
IV, read full text
Our other product: