STM32F407移植uCOSII笔记_第1页
STM32F407移植uCOSII笔记_第2页
STM32F407移植uCOSII笔记_第3页
STM32F407移植uCOSII笔记_第4页
STM32F407移植uCOSII笔记_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、STM32F407在IAR环境下移植Ucos-II第一步:安装IAR for ARM。第二步:建一个文件夹,最好用工程名命名。第三步:在新建的文件夹下面建7个文件夹,分别是:app、bsp、libraries、Project、si、ucos-ii、user,建好的文件夹见下图(图一):图 1第四步:准备好STM32F4XX的固件库。见图二、图三:图 2图 3第五步:准备好uCOS-II源码。我的源码路径为:E:项目文件电阻焊控制器V2参考资料ucos源码MicriumSoftwareuCOS-II;见图4、图5、图6、图7、图8:图 4图 5图 6图 7图 8第六步:将第四步中准备好的stm3

2、2固件库里libraries下的文件拷贝到工程文件夹下的libraries文件夹里。第七步:将第五步中准备好的uCOS-II源码文件夹里的Ucos-II文件夹中的ports、source两个文件夹拷贝到工程文件夹下的ucos-ii文件夹中。图 9第八步:打开IAR,filenewworkspace先建一个工作空间。第九步:建立一个工程,projectcreate new project,在工程文件管理器中新建组 ,右键单击工程名addadd group,并给每个组添加相应的文件(右键单击工程名addadd file);添加好文件的窗口如下图:图 10第10步:IAR配置,右键单击工程名opti

3、ons,跳出如下图所示窗口:图 111、 在General Options项中的 Device中选择芯片,其他项默认值OK;2、 在library configuration页中的library选择Full,否则会编译会保错,将右下角的Use CMSIS勾上。其他项保持默认值。图 123、 在C/C+ Compiler项中的Preprocessor也中添加头文件路径($PROJ_DIR$表示工程路径,$PROJ_DIR$.是工程路径的父目录),并添加宏定义(USE_STDPERIPH_DRIVER、STM32F10X_HD),添加好的窗口见下图:图 134、 在Linker项中的cofig页中

4、Override default。如下图:图 145、 在debugger中的setup中选择自己用的仿真器。如下图:图 156、 仿真器设置页见下图:图 16到此软件配置完毕。第11步:在组App中新建app.c或者拷贝一个过来,将里面的内容全部删除,自己写。同样建立一个includes.h文件,includes.h文件下的内容图下:图 17App.c的内容可以这样写:#include <includes.h>#include <app_cfg.h>/* LOCAL DEFINES*/* LOCAL GLOBAL VARIABLES*/static OS_STK ta

5、sk_startup_stkSTARTUP_TASK_STK_SIZE;static OS_STK task1_stkTASK1_STK_SIZE;static OS_STK task2_stkTASK2_STK_SIZE;u8 os_err;static void systick_init(void) RCC_ClocksTypeDef rcc_clocks; RCC_GetClocksFreq(&rcc_clocks); SysTick_Config(rcc_clocks.HCLK_Frequency/OS_TICKS_PER_SEC);/CM4内核库文件中调用int main(v

6、oid)/ systick_init();/ BSP_Init();OSInit();OSTaskCreate(Task_startup,(void*)0,&task_startup_stkSTARTUP_TASK_STK_SIZE-1,STARTUP_TASK_PRIO);OSStart(); return 0; static void BSP_Init(void)LEDGpio_Init();usart1_init(9600);static void Task_startup(void *p_arg)systick_init(); BSP_Init();#if(OS_TASK_ST

7、AT_EN > 0) OSStatInit();#endif OSTaskCreate(Task1_CAN_Check,(void*)0,&task1_stkTASK1_STK_SIZE-1,TASK1_PRIO); OSTaskCreate(Task2_Disp_Com, (void*)0, &task2_stkTASK2_STK_SIZE-1, TASK2_PRIO ); OSTaskDel(OS_PRIO_SELF);static void Task1_CAN_Check(void *p_arg)while(1)GPIO_WriteBit(GPIOE,GPIO_Pi

8、n_0,1-GPIO_ReadOutputDataBit(GPIOE,GPIO_Pin_0);OSTimeDlyHMSM(0,0,0,250);/LED1_ONOFF(Bit_SET);/ OSTimeDlyHMSM(0,0,0,250);/ LED1_ONOFF(Bit_RESET);/OSTimeDlyHMSM(0,0,0,250);static void Task2_Disp_Com(void *p_arg)while(1)LED2_ONOFF(Bit_SET); OSTimeDly(500); LED2_ONOFF(Bit_RESET); OSTimeDly(500);建一个stm32

9、f4xx_conf.h文件或拷贝一个,内容如下:/* * * file ADC/DualADC_RegulSimu_DMAmode1/stm32f4xx_conf.h * author MCD Application Team * version V1.0.0 * date 30-September-2011 * brief Library configuration file. * * attention * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING

10、INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING

11、INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. * * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2> * */ /* Define to prevent recursive inclusion -*/#ifndef _STM32F4xx_CONF_H#define _STM32F4xx_CONF_H/* Includes -*/* Uncomment the line be

12、low to enable peripheral header file inclusion */#include "stm32f4xx_adc.h"#include "stm32f4xx_can.h"#include "stm32f4xx_crc.h"#include "stm32f4xx_cryp.h"#include "stm32f4xx_dac.h"#include "stm32f4xx_dbgmcu.h"#include "stm32f4xx_dcmi.h

13、"#include "stm32f4xx_dma.h"#include "stm32f4xx_exti.h"#include "stm32f4xx_flash.h"#include "stm32f4xx_fsmc.h"#include "stm32f4xx_hash.h"#include "stm32f4xx_gpio.h"#include "stm32f4xx_i2c.h"#include "stm32f4xx_iwdg.h"

14、;#include "stm32f4xx_pwr.h"#include "stm32f4xx_rcc.h"#include "stm32f4xx_rng.h"#include "stm32f4xx_rtc.h"#include "stm32f4xx_sdio.h"#include "stm32f4xx_spi.h"#include "stm32f4xx_syscfg.h"#include "stm32f4xx_tim.h"#includ

15、e "stm32f4xx_usart.h"#include "stm32f4xx_wwdg.h"#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */* Exported types -*/* Exported constants -*/* If an external clock source is used, then the value of the following define should

16、be set to the value of the external clock source, else, if no external clock is used, keep this define commented */*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */* Uncomment the line below to expanse the "assert_param" macro in the Standard Peripheral Li

17、brary drivers code */* #define USE_FULL_ASSERT 1 */* Exported macro -*/#ifdef USE_FULL_ASSERT/* * brief The assert_param macro is used for function's parameters check. * param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * lin

18、e number of the call that failed. * If expr is true, it returns no value. * retval None */ #define assert_param(expr) (expr) ? (void)0 : assert_failed(uint8_t *)_FILE_, _LINE_)/* Exported functions - */ void assert_failed(uint8_t* file, uint32_t line);#else #define assert_param(expr) (void)0)#endif /* USE_FULL_ASSERT */#endif /* _STM32F4xx_CONF_H */* (C) COPYRIGHT 2011 STMicroelectronics *END OF FILE*/第十二步:修改启动文件:1、 将所有的SECTION .text:CODE:REORDER (1)替换为SECTION .text:CODE:REORDER:NOROOT(1),否则iar会报错。2、 将所有的PendSV Handler用OS_CPU_PendSVHandler替换3、 将所有的SysTick

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论