Configuring FreeRTOS V8.2.3

Source: Internet
Author: User

The FreeRTOS is highly configurable. All the configurable items are in the FreeRTOSConfig.h file. Each demo program contains a well-configured FreeRTOSConfig.h file that can be modified based on the FreeRTOSConfig.h file in the demo program as a template.

A typical FreeRTOSConfig.h file is given below, which is then described in one item.

/* FreeRTOS v8.2.3-copyright (C) Real time Engineers Ltd.    All rights reserved VISIT http://www.FreeRTOS.org to ensure is USING the LATEST VERSION.    This file is part of the FreeRTOS distribution. FreeRTOS is free software; You can redistribute it and/or modify it under the terms of the GNU general public License (version 2) as published by    The free software Foundation >>>> and MODIFIED by <<<< the FreeRTOS exception.   >>!   Note:the modification to the GPL are included to allow you to!<< >>!   Distribute a combined work that includes freertos without being!<< >>!   Obliged to provide the source code for proprietary components!<< >>!                                   Outside of the FreeRTOS kernel.  !<< ***************************************************************************  FreeRTOS is distributed on the hope that it'll be being useful, but without any WARRANTY;  Without even the implied warranty of merchantability or FITNESS for A particular PURPOSE. Full license text was available on the following link:http://www.freertos.org/a00114.html **************************                                                                       *************************************************     * * * FreeRTOS provides completely free yet professionally developed, * * Robust, strictly quality cont     Rolled, supported, and cross * * Platform software that's more than just the market leader, it *                               * is the industry ' s de facto standard.  * * * * Help yourself get started quickly    While simultaneously helping * to support the FreeRTOS project by purchasing a freertos * * Tutorial BOok, reference Manual, or both: * * http://www.                                                                       Freertos.org/documentation * * * *************************************************************************** http://www.  Freertos.org/faqhelp.html-having a problem?  Start by reading the FAQs page "My application does not run, what could is wrong?".    Have you defined Configassert ()? http://www. Freertos.org/support-in return for receiving this top quality embedded software for free We request your assist our GL    Obal community by participating in the Support forum. http://www.  Freertos.org/training-investing in training allows your team to be as productive as possible as early as possible. Now your can receive FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers Ltd., and the world ' s L    Eading authority on the world ' s leading RTOS. http://www. freertos.org/plus-a selection of FreeRTOS ecosystem products, including freertos+trace-an indispensable productivity tool, A do    S compatible FAT file system, and our tiny thread aware UDP/IP stack. http://www.    Freertos.org/labs-where new FreeRTOS products go to incubate.    Come and try Freertos+tcp, our new Open source TCP/IP stack for FreeRTOS. http://www. Openrtos.com-real Time Engineers Ltd. license FreeRTOS to High Integrity Systems Ltd. to sell under the Openrtos Bran    D. Openrtos licenses offer ticketed support, indemnification and commercial middleware. http://www.  Safertos.com-high Integrity Systems also provide a safety engineered and independently SIL3 certified version for use    In safety and mission critical applications that require provable dependability. 1 Tab = = 4 spaces!*/#ifndef freertos_config_h#define freertos_config_h/*-------------------------------------------- ---------------* Application specific definitions. * * These definitions Should is adjusted for your particular hardware and * application requirements.  * * These PARAMETERS is described within the ' CONFIGURATION ' section of the * FreeRTOS API documentation AVAILABLE on the  freertos.org WEB SITE. * * See http://www.freertos.org/a00110.html. *----------------------------------------------------------*/#define CONFIGUSE_PREEMPTION1 #define Conf Iguse_idle_hook0#define configuse_tick_hook0#define configcpu_clock_hz ((unsigned long) 72000000) #define ConfigTICK_ Rate_hz (ticktype_t) #define CONFIGMAX_PRIORITIES (5) #define CONFIGMINIMAL_STACK_SIZE ((unsigned short) 128) # Define Configtotal_heap_size ((size_t) (17* 1024x768)) #define CONFIGMAX_TASK_NAME_LEN (+) #define Configuse_trace_facili Ty0#define configuse_16_bit_ticks0#define configidle_should_yield1/* co-routine definitions. */#define Configuse_co_routines 0#define configmax_co_routine_priorities (2)/* Set the following definitions to 1 to Inc Lude the API function, or ZEroto exclude the API function. */#define Include_vtaskpriorityset1#define include_uxtaskpriorityget1#define include_vtaskdelete1#define INCLUDE_ Vtaskcleanupresources 0#define include_vtasksuspend1#define include_vtaskdelayuntil1#define INCLUDE_vTaskDelay1/*  This is the raw value as per the cortex-m3 NVIC. Values can 255 (lowest) to 0 (1?) (highest). */#define CONFIGKERNEL_INTERRUPT_PRIORITY 255/*!!!! Configmax_syscall_interrupt_priority must not is set to zero!!!! See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */#define CONFIGMAX_SYSCALL_INTERRUPT_PRIORITY 191/* equivalent To 0xb0, or priority 11.  *//* the value being used as per the ST library which permits 16priority values, 0 to 15.  This must correspond to theconfigkernel_interrupt_priority setting. Here's corresponds to the Lowestnvic value of 255. */#define CONFIGLIBRARY_KERNEL_INTERRUPT_PRIORITY15#ENDIF/* Freertos_config_h */

  

Configurable parameters
Configuse_preemption
Set to 1 is a preemptive scheduler, set to 0 is the use of cooperative scheduler.

Configuse_idle_hook
Set to 1 to enable idle hook, set to 0 to prohibit the idle hook.

Configuse_tick_hook
Set to 1 to enable the tick hook, set to 0 to prohibit the tick hook.

Configcpu_clock_hz
Set to the operating frequency of the MCU core, in Hz. Used when configuring the FreeRTOS clock tick. This parameter may also not be used for different porting code. If you decide not to use it in your porting code, you can comment out the line.

Configtick_rate_hz
The frequency of the clock tick of the FreeRTOS, which is the frequency at which the FreeRTOS is used to generate the timer interrupt. The higher the frequency, the higher the accuracy of timing, but the greater the overhead. FreeRTOS comes with a demo program to set Tickrate to 1000Hz just to test the performance of the kernel. The actual application should be changed to a smaller number as needed.
When multiple tasks share a priority, the kernel scheduler returns to the switch task (round robin) every time the clock break arrives, so higher tick rate causes the task's time slice to be shorter.

Configmax_priorities
The maximum priority that can be used in a program. FreeRTOS creates a linked list for each priority, so that no more priority increases the overhead of RAM. So, set this parameter according to how many different priorities you need in your program.

Configminimal_stack_size
The minimum size of the task stack, FreeRTOS allocates stack space for the idle task based on this parameter. This value can cause the program to hang if it is set to a smaller space than is actually needed. Therefore, it is best not to reduce the size given in the demo program.

Configtotal_heap_size
Sets the size of the heap space (heap). This is only used if the memory allocation algorithm provided by FreeRTOS is used in the program.

Configmax_task_name_len
The maximum length of the task name, which is in bytes and includes the last NULL end byte.

Configuse_trace_facility
If you need trace functionality in your program, you need to set this macro to 1. Otherwise set to 0. When the trace function is turned on, ram consumption increases a lot, so think twice before setting it to 1.

Configuse_16_bit_ticks
When Configuse_16_bit_ticks is set to 1, Portticktype is defined as an unsigned 16-bit shape type, and portticktype is defined as an unsigned 32-bit integer after Configuse_16_bit_ticks is set to 0.

Configidle_should_yield
This parameter controls the behavior of those tasks with the same priority as the idle task, and is only useful if the kernel is configured as a preemptive Task scheduler.
The kernel uses the time-slice rotation scheduling algorithm for tasks with the same priority. When a task has a higher priority than an idle task, the time slices for each task are the same size.
But it's a little different when the priority of the task is the same as the idle task. When Configidle_should_yield is configured to 1 o'clock, when any task with the same priority as the idle task is in the ready state, the idle task immediately requires the scheduler to switch tasks. This causes the idle task to take up the least amount of CPU time, but it also makes the time slices not equal in priority with the same tasks as the idle task. Because the idle task consumes part of the time slice of a task.

Configuse_mutexes
Set to 1 The program will contain mutex-related code, set to 0 to ignore the relevant code.

Configuse_recursive_mutexes
Set to 1 The program will contain recursive mutex-related code, set to 0 to ignore the relevant code.

Configuse_counting_semaphores
Set to 1 The program will contain semaphore-related code, set to 0 to ignore the relevant code.

Configuse_alternative_api
Set to 1 The program will contain some additional API functions for queue operations, set to 0 to ignore the relevant code. These additional APIs run faster, but the critical section (off interrupt) is longer. Pros and cons, whether to use the user needs to consider their own.

Configcheck_for_stack_overflow
Controls whether stack overflow is detected.

Configqueue_registry_size
The queue registry has two functions, but both roles depend on the debugger's support:
1. Give the queue a name that makes it easier to identify which queue to debug.
2. Contains specific information required by the debugger to locate queues and semaphores.
If your debugger does not have the above features, which of these registry is useless, also occupies the valuable RAM space.

Configgenerate_run_time_stats
Sets whether to generate run-time statistics that are only useful for debugging and that are saved in RAM and occupy Ram space. Therefore, the final program is recommended to be configured to not generate run-time statistics.

Configuse_co_routines
Set to 1 contains the Co-routines feature, and if the Co-routines feature is included, compile with the croutine.c file

Configmax_co_routine_priorities
Co-routines the number of priority levels that can be used.

Configuse_timers
Set to 1 to include the software timer function.

Configtimer_task_priority
Sets the priority of the Software Timer task.

Configtimer_queue_length
Sets the length of the command queue used in the software timer task.

Configtimer_task_stack_depth
Set the task stack size required by the software Timer task.

configkernel_interrupt_priority and configmax_syscall_interrupt_priority
CORTEX-M3, PIC24, DsPIC, PIC32, SuperH, and RX600 are used in the porting code to configkernel_interrupt_priority.
PIC32, RX600 and CORTEX-M series will be used to configmax_syscall_interrupt_priority
Configkernel_interrupt_priority should be set to the lowest priority.

For those systems that only define the configkernel_interrupt_priority:
Configkernel_interrupt_priority determines the priority used by the FreeRTOS kernel.
All interrupts that call API functions should have the priority set to this value, and interrupts that do not invoke API functions can be set to a higher priority.

For those systems that define the configkernel_interrupt_priority and configmax_syscall_interrupt_priority:
Configkernel_interrupt_priority determines the priority used by the FreeRTOS kernel.
Configmax_syscall_interrupt_priority determines the highest priority of interrupts that can invoke API functions. An interrupt handler above this value cannot call any API function.

Configassert
Macro Configassert () acts like macro assert () in the standard library of C, Configassert () can help with debugging, but after Configassert () is defined, the program code is added and the program slows down.

Start with include parameter
Macros that start with ' INCLUDE ' allow us to exclude some of the unwanted API functions from compiling the generated code. This allows the kernel code to consume less ROM and RAM.
For example, if you need to use the Vtaskdelete function in your code, write this:
#defineINCLUDE_vTaskDelete 1
If it is not needed, write this:
#defineINCLUDE_vTaskDelete 0

Configuring FreeRTOS V8.2.3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.