file-type

STM32F103开发板成功移植UCOSIIV2.52系统

RAR文件

5星 · 超过95%的资源 | 下载需积分: 10 | 61KB | 更新于2025-06-10 | 147 浏览量 | 27 下载量 举报 1 收藏
download 立即下载
知识点详述: 1. UCOSII的介绍和应用: - UCOSII(MicroC/OS-II)是一个用于嵌入式系统的实时操作系统内核,它具有抢占式多任务处理能力,广泛应用于实时控制领域。 - UCOSII支持多任务并发执行,通过任务调度器对任务进行管理和调度,以实现高效的任务切换和资源管理。 - 它需要具备操作系统基础,如任务管理、信号量、邮箱、消息队列、定时器、内存管理等概念。 2. STM32F103系列微控制器: - STM32F103是由STMicroelectronics(意法半导体)生产的一款基于ARM Cortex-M3内核的高性能微控制器。 - 此系列微控制器具有丰富的外设接口,如I2C、SPI、UART等,以及高性能的处理速度和丰富的中断管理功能,适用于工业控制、医疗设备、消费类电子产品等多种应用领域。 - STM32F103RB是系列中的一个型号,具备256KB闪存和48KB的SRAM。 3. 移植过程: - 移植(Porting)是指将软件从一个平台转移到另一个平台的过程。对于嵌入式系统来说,主要是指将操作系统或应用程序从一种硬件平台转移到另一种硬件平台的过程。 - 移植UCOSII到STM32F103涉及修改内核代码,使其适应新硬件平台的特定硬件特性,如中断处理、内存管理、时钟等。 - 在这个过程中,通常需要修改OS_CPU_A.ASM文件来适配新的处理器架构,比如改变栈操作、中断响应等。 4. 源代码的修改和测试: - 移植时通常需要对源代码进行必要的修改,以确保操作系统能正确地运行在目标硬件上。 - 修改可能包括配置文件的设置,如时钟频率、内存大小、中断向量等。 - 实验测试是确保修改后的代码能在目标硬件上稳定运行的关键步骤,通常涉及创建一些基础任务、信号量、定时器等来验证系统的实时性能。 5. 文件命名规则和结构: - STM32F10x_it.C和STM32F10x_it.h文件的命名中,STM32F10x代表了与STM32F103系列微控制器相关的文件,而_it后缀通常表示中断处理相关的文件。 - C文件是源代码文件,通常包含中断服务例程和其他中断处理函数;.h文件是头文件,包含中断处理函数的声明和其他宏定义。 - 在本案例中,将中断函数PendSVC注释掉意味着在移植过程中,该中断服务例程不需要或者被另外的代码替代,以避免与UCOSII中的相应处理发生冲突。 6. 应用层代码的适配: - 在成功移植UCOSII到STM32F103之后,需要根据实际应用场景对应用层代码进行适配。 - 应用层代码通常涉及外设控制、传感器数据采集、通信协议实现等,需要根据目标硬件的特性来编写或修改。 7. 开发环境和工具: - 为了移植UCOSII到STM32F103,开发者需要熟悉Keil、IAR等集成开发环境(IDE),这些环境提供了编译器、调试器等工具,用于代码的编写、编译、调试和烧录。 - 还需要具备使用ST-Link、J-Link等调试器进行硬件调试的经验。 通过以上详述,可以看出移植UCOSII到STM32F103RB是一个复杂的过程,不仅需要深厚的嵌入式系统知识,还需要对操作系统内核、微控制器硬件特性和开发环境有深入理解。完成这个过程需要精心的设计、细致的调试,以及对开发工具的熟练使用。

相关推荐

filetype
/*********************** (C) COPYLEFT 2010 Leafgrass *************************/ This project runs on uC/OS-II V2.52 and is based on STM32F103RBT6(ARM Cortex-M3 Core) Take care of the configuration of project. There're some Include Paths while linking which cannot be modified. Procedure of driving a device(IMPORTANT!!!): 1.Connect hardware correctly. 2.Prepare DEVICE_NAME.h and DEVICE_NAME.c. 3.Enable clock of related components. 4.Enable related interrupt while configure NVIC. 5.Configure related IO pins. 6.Finish test code and begin testing. 2010-06-10( original ): Sucessfully port uCOS-II V2.52. 2010-06-11: Add code "SysTick_CounterCmd(SysTick_Counter_Enable);" in SysTick_Configuration(), solve the problem that the program can't get into SysTickHandler(), as below: /******************************************************************************* * Function Name : SysTick_Config * Description : Configures SysTick * Input : None * Output : None * Return : None *******************************************************************************/ void SysTick_Configuration(void) { NVIC_SystemHandlerPriorityConfig(SystemHandler_SysTick, 0, 1); /* Configure HCLK clock as SysTick clock source */ SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8); /* SysTick interrupt each 1000 Hz with HCLK equal to 72MHz */ SysTick_SetReload(9000); /* Enable the SysTick Interrupt */ SysTick_ITConfig(ENABLE); SysTick_CounterCmd(SysTick_Counter_Enable); //Important!! Solve "the program can't get into SysTickHandler()!! } 2010-06-12( updates to V1.0 ): 1. Add EXTI8, EXTI9 on PC8, PC9, only for EXTI test. 2. Modify some comments in LCD5110_lib. 3. (in main.c) Modifiy tasks' priority LED_TASK_Prio 1 -> 5 START_TASK_Prio 2 -> 10 4. (in main.c) Modify code "OSTaskDel(START_TASK_Prio);" to "OSTaskSuspend(START_TASK_Prio);" 2010-07-13 1.Drive LTM022A69B LCD ok. Just use I/O to imitate SPI. Still cannot use internal SPI to drive it. 2.Move LCD library of LTM022A69B into "LCD_lib.c". 2010-07-15: Add color bar display in LCD_test(). 2010-07-16( updates to V1.1 ): 1.Solve problem about position error and color error, when display a set of 16-bit color data. Mainly resulted from CPU type, big endian or little endian. STM32F103RBT6 is little endian while in default set. 2.Add Draw_img(); 3.Add colorful characters and strings, add parameters about colors in display functions.(colors are defined in LTM022A69B.h) 2010-07-17: 1.Add comments in LCD_Init(). 2.Add parameter "color" to function Draw_dot(). 3.Add function SetCursor(). 4.Unify LCD related functions' name. Add prefix "LCD_". 2010-07-19: Modify data type in LCD_Lib. normal --> const. At one time, modify the pointers type to const. 2010-07-20: 1.Correct the error that OSTimeDlyHMSM() can't delay an accurate time, by modifying SysTick_Configuration() to get an correct clock frequency. 2010-07-31: Add STM32_Init.c but is not referenced, for future use of Configuration Wizard. 2010-08-01: Configure SPI ok, and do some test(SPI2 tx -> SPI1 rx, display on LCD). 2010-08-03: 1.Add SPI test code in main.c, SPI2 send data, SPI1 receive data , display info on LCD, use soft SPI. 2.Add exported macro "USESPI" to choose if use SPI to drive LCD or not. 3.After several days researching about hard SPI to drive LCD, failed. So switch to use a faster GPIO method, as below: Replace "#define LCD_RST_H() GPIO_SetBits(LCD_CTRL_PORT, LCD_RST)" in ST library with "#define LCD_RST_H() ( LCD_CTRL_PORT->BSRR = LCD_RST )" for a faster LCD refresh speed. 4.Modify name "LCD_SCI" to "LCD_SI", 'cause it means Serial Interface. 5.Modify function name "LCD_test()" to "LCD_Test()". 2010-08-06: Comment off "typedef enum {FALSE = 0, TRUE = !FALSE} bool;" in stm32f10x.type.h in order to avoid warning. 2010-08-09: Prepare to update to v2.0. 2010-08-10( Update to v2.0, use ST's FWLib3.1.2 ): 1. Set project(Keil RealView MDK). (1) RO memory area : IROM1 -- start at 0x08000000, size 0x20000. (2) RW memory area : IRAM1 -- start at 0x20000000, size 0x5000. (3) Output setup. (4) Listing setup, no assembler list. (5) C/C++ setup. Preprocessor Symbols : Define -- USE_STDPERIPH_DRIVER, STM32F10X_MD. Include Paths : ..\; ..\..\Libraries\CMSIS\Core\CM3; ..\..\Libraries\STM32F10x_StdPeriph_Driver\inc; ..\..\App; ..\..\Driver; ..\..\OS; ..\..\OS\port (6) Linker, Use memory layout from target dialog. (7) Debug and Utilities, Cortex-M/R J-Link/J-Trace. Disable Trace. 2. Modify code in "includes.h". 3. Modify startup code, did not use the st original one. Port those used in FWLib2.0 instead. Of course, some code are revised for FWLib3.1.2(StdPeriph_Driver and CMSIS). Mainly rewrite the names of the ISR. The most important two are : "PendSV_Handler" and "SysTick_Handler". ---> "OSPendSV" and "SysTick_Handler". (in "os_cpu_a.asm") (in "stm32f10x_it.c") 4. Modify initial code for SysTick in "SysTick_Configuration()" in "CPU_Init.c" because of the changing of library. Note : A general problem is that program always go into "B OSStartHang" in "OSStartHighRdy" in "os_cpu_a.asm", and will die in there... That's caused by program hasn't step into the correct ISR yet. Enable the SysTick interrupt, check if the name of Interrupt Service Routines are right, then all will be OK. 5. Still some problem with retargeting "printf()". If use "printf()" in program, system wouldn't run. 6. Change Project name to "RTOS_STM32". 2010-08-11( Update to v2.1, use ST's FWLib3.3.0 ): 1. Modify Include Path in Target Options. 2. Comment "typedef enum {FALSE = 0, TRUE = !FALSE} bool;" off in order to avoid error: "..\stm32f10x.h(454): error: #40: expected an identifier". 2010-08-12( Update to v2.2 ): 1. Remove the incorrect use of SPI in LCD display, add a new schedule( maily used SPI busy flag ). 2. Commen off code "assert_param(IS_SPI_ALL_PERIPH(SPIx));" in "SPI_I2S_SendData()", "SPI_I2S_ReceiveData()", and "SPI_I2S_GetFlagStatus" in "stm32f10x_spi.h", in order to improve LCD refresh frequency. 3. Finish to retarget C library printf() to UART. As a foundation, change the setup of KEIL in "Target Options" --> "Code Generation" --> tick "Use MicroLIB". There are still some problem with building, modify a few lines in "stm32f10x_startup.s" : ================================ IF :DEF:__MICROLIB EXPORT __initial_sp EXPORT __heap_base EXPORT __heap_limit ELSE IMPORT __use_two_region_memory EXPORT __user_initial_stackheap ================================ Then rebuild. Add retarget code in main.c : ================================================================ #ifdef __GNUC__ // With GCC/RAISONANCE, small printf // (option LD Linker->Libraries->Small printf set to 'Yes') // calls __io_putchar() #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif // __GNUC__ ---------------------------------------------------------------- PUTCHAR_PROTOTYPE { // Place your implementation of fputc here // e.g. write a character to the USART USART_SendData(USARTx, (u8)ch); // Loop until the end of transmission while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) {} return ch; } ================================================================ 2010-08-14(update to v2.3): 1. Rewrite the different part of code into its C file. 2. Drive TIM3 output PWM wave successfully. 3. Add "servo" file, for servo control. 2010-08-19(update to v2.4, GPS data receive ok): 1. Add "gps" file. 2. Add code in "USART3_IRQHandler()", mainly to receive data from GPS. But there's still someting confusing, that the pair "USART_ITConfig(USART3, USART_IT_RXNE, DISABLE);" and "USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);" cannot work well. Because once use them, some data will be lost. 2010-08-22: Refresh firmware of GPS, modify to Baudrate 9600, China timezone, WGS-84 coordinate. 2010-09-02: Replace those two old startup files "cortexm3_macro.s" and "stm32f10x_startup.s" with the one "startup_stm32f10x_md.s" which is created by MCD Application Team in FWLib3.3.0. 2010-09-13: 1. Add general_task.h and .c for miscellaneous experimental purpose. 2. Add uart output infomation in booting stage. 3. Add macro "LED_TOGGLE()" use "(GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1))" 4. Create Logo: _ _ / / | | ___ __ _ _| |_ __ _ _ __ __ _ _ _ | | / _ \/ _` |_ _/ _` | \/ _)/ _` | / / / / | |_ _ __( (_| | | | (_| | | | ( (_| | \ \ \ \ |_ _ _\___|\__,_| | | \__, / | | \__,_| /_/ /_/ /_/ \_ _/ 5. EXTI again. setup procedure: GPIO IN FLOATING -> NVIC IRQ -> EXTI Config -> _it.c /*********************** (C) COPYLEFT 2010 Leafgrass *************************/
胖祥
  • 粉丝: 19
上传资源 快速赚钱