UCOS2_STM32F1 Transplant Detailed procedure (ii)

Source: Internet
Author: User

Ⅰ, Overview

Open the previous article new project, is to extract the St standard library inside source code files and Ucos project package source code files. Downloaded friends may know that the direct compilation of the project will have a large number of errors and warnings, because the project is not modified source code of the project, followed by a step-by-step process to modify the source code (known as the transplant process).

This article goes on to describe the "Ucos transplant detailed process", the previous article is about preparation, file extraction and collation, new Ucos engineering work. This article describes the work of modifying source code (underlying code, system configuration, and so on) during the Ucos migration.

I will "ucos transplant detailed process" into a number of articles to tell, please pay attention to.

See below for details of this article (please click on "read the original text" To view the content link).

based on the principle of free sharing, easy to learn knowledge of mobile phones, regularly share technical knowledge on the platform. If you feel that the content you share is useful to you, and if you want to learn more about it, please use the search "embedddeveloper" or scan the QR code below and follow There will be more exciting content waiting for you.

Ⅱ, St Chip Configuration

There are two ways to configure the ST Model: using standard library Source code configuration and Engineering configuration

1. Source Code Configuration

Open Project, open the source code "stm32f10x.h" file.

Using F103 Large-capacity chip: Uncomment the 68th line of STM32F10X_MD, which needs to match our startup code STARTUP_STM32F10X_HD.S.

Using the standard Peripherals Library: Uncomment the 105th line Use_stdperiph_driver, using the standard peripherals Library, we use the Stm32f10x_conf.h file to configure the used peripheral libraries.

2. Project configuration

Open Project---project, options for Target, C/C + +, add the two macro definitions within the predefined options.

Note: You can use one of two methods. As follows:

Ⅲ, Configuring the system tick Clock

System operation can not be separated from the system tick, as I said before: the role of the system tick, is to drive the whole system to work the heart, if not, it is equal to the person has no heartbeat.

1. Initialize Ticks

We use the tick SysTick of the St to configure the tick clock as the operating system, and the chip SysTick is part of the kernel (CORTEX-M3), so the source code (Systick_config function) is called in CM3 when initializing.

Here is a description, as long as the use of CORTEX-M3 core chip has this function, it can be said that Systick is designed specifically for the system.

The system tick configuration, such as, is located under the app_cfg.c source file.

2. Tick Interrupt Configuration

The interrupt function needs to call the system-related functions, that is, the system tick-related functions, here is the rule so called.

Ⅳ, Cutting System (configuration Os_cfg.h)

We often say that the system can be cropped, in fact, some functions of the system is turned on and off, the use of the function to open, the function is not used to close (even if can and lose), this file is concentrated in the Os_cfg.h file.

Here are a few important options to consider:

1. Lowest-priority Os_lowest_prio

This is the maximum value of the minimum priority task configuration that is related to our configuration task priority. We call the task priority relationship: the smaller the priority, the greater the value; Conversely, the higher the priority, the smaller the value.

On line 39th of the Os_cfg.h file:

#define Os_lowest_prio 63

2. System tick count per second os_ticks_per_sec

This macro definition means that the system ticks every second, it is more important than the system delay (ostimedly) relationship, our example os_ticks_per_sec equals 100, call ostimedly (100), equivalent to the delay of 100 ticks, That means delay of 1 seconds.

On line 51st of the Os_cfg.h file:

#define OS_TICKS_PER_SEC 100

3. Task Stack size Os_task_xxx_stk_size

These macro definitions are useful when using the appropriate features, and if the RAM resources are limited, the task stack is best evaluated according to the task, not too large in resources, and certainly not less than the program is working.

In the Os_cfg.h file 第55-57 line:

#define OS_TASK_TMR_STK_SIZE 128



4. Other

There are many other resources related to the system configuration, the normal situation is required when the time to open, do not close as much as possible. One is to conserve resources, and the second is to reduce compilation time. Later I will comment the Chinese in the back.

Ⅴ, Download

I will complete the transplant, set up 3 simple task routines on the 360 cloud disk for everyone to download and reference:

Https://yunpan.cn/cRIpR5bwHMCCY access password 3885

UCOS2 based on STM32F107 Software engineering Package (official website original):

Micrium Official website (requires account):


I 360 Cloud disk:

Https://yunpan.cn/cRzcf8eSacEhE access password 1235

Standard Peripherals Library:

ST Official website (need account):

Http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/ stm32-embedded-software.html?querycriteria=productid=sc961

I 360 cloud disk (updated regularly):

https://yunpan.cn/cSaCpGejMSfr8 access password 60ae

Ⅵ, Description

Related articles can be viewed on my blog, I will also update regularly, new content is the first time to share.

When you master the porting of Ucos on one platform, other platforms are similar in principle, please do not limit a certain platform.

The above summary is for reference only, if has the wrong place, please understanding.

Ⅶ, finally

Attention, reply to "more content", will get more content (such as:UCOS instances, etc., constantly updated in ...) )。

If you like what I share, and you want to know more about it, please follow the public number at the beginning of the article, the new content continues to be updated, and more exciting content will appear later.

Previous post

UCOS2_STM32F1 Transplant Detailed procedure (ii)

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.