uCOSII-V2.52在单片机STC12C5A60S2上移植方法

上传人:na****u 文档编号:56504721 上传时间:2022-02-21 格式:DOCX 页数:31 大小:33.70KB
收藏 版权申诉 举报 下载
uCOSII-V2.52在单片机STC12C5A60S2上移植方法_第1页
第1页 / 共31页
uCOSII-V2.52在单片机STC12C5A60S2上移植方法_第2页
第2页 / 共31页
uCOSII-V2.52在单片机STC12C5A60S2上移植方法_第3页
第3页 / 共31页
资源描述:

《uCOSII-V2.52在单片机STC12C5A60S2上移植方法》由会员分享,可在线阅读,更多相关《uCOSII-V2.52在单片机STC12C5A60S2上移植方法(31页珍藏版)》请在装配图网上搜索。

1、uCOSII V2.52移植到STC12C5A60S2单片机上uCOSII版本:V2.52单片机型号:STC12C5A60S2说明:代码注释中有乱码,不影响程序,因为编码机制不同导致修改文件1:启动文件STARTUP.A51,修改部分红色字体标出$NOMOD51;-; This file is part of the C51 Compiler package; Copyright (c) 1988-2005 Keil Elektronik GmbH and Keil Software, Inc.; Version 8.01; * *;-; STARTUP.A51: This code is e

2、xecuted after processor reset.; To translate this file use A51 with the following invocation:; A51 STARTUP.A51; To link the modified STARTUP.OBJ file to your application use the following; Lx51 invocation:; Lx51 your object file list, STARTUP.OBJ controls;-; User-defined Power-On Initialization of M

3、emory; With the following EQU statements the initialization of memory; at processor reset can be defined:; IDATALEN: IDATA memory size ; Note: The absolute start-address of IDATA memory is always 0; The IDATA space overlaps physically the DATA and BIT areas.IDATALEN EQU 80H; XDATASTART: XDATA memory

4、 start address ; The absolute start address of XDATA memoryXDATASTART EQU 0 ; XDATALEN: XDATA memory size ; The length of XDATA memory in bytes.XDATALEN EQU 0 ; PDATASTART: ppdata memory start address ; The absolute start address of ppdata memoryPDATASTART EQU 0H; PDATALEN: ppdata memory size ; The

5、length of ppdata memory in bytes.PDATALEN EQU 0H;-; Reentrant Stack Initialization; The following EQU statements define the stack pointer for reentrant; functions and initialized it:; Stack Space for reentrant functions in the SMALL model.; IBPSTACK: Enable SMALL model reentrant stack; Stack space f

6、or reentrant functions in the SMALL model.IBPSTACK EQU 0 ; set to 1 if small reentrant is used.; IBPSTACKTOP: End address of SMALL model stack ; Set the top of the stack to the highest location.IBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1 ; ; Stack Space for reentrant functions in the LARGE model. ; XBP

7、STACK: Enable LARGE model reentrant stack; Stack space for reentrant functions in the LARGE model.XBPSTACK EQU 1 ; set to 1 if large reentrant is used.; XBPSTACKTOP: End address of LARGE model stack ; Set the top of the stack to the highest location.XBPSTACKTOP EQU 0xFFFF +1 ; default 0FFFFH+1 ; ; S

8、tack Space for reentrant functions in the COMPACT model. ; PBPSTACK: Enable COMPACT model reentrant stack; Stack space for reentrant functions in the COMPACT model.PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.; PBPSTACKTOP: End address of COMPACT model stack ; Set the top of the stack to t

9、he highest location.PBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1 ; ;-; Memory Page for Using the Compact Model with 64 KByte xdata RAM; Compact Model Page Definition; Define the XDATA page used for ppdata variables. ; PPAGE must conform with the PPAGE set in the linker invocation.; Enable ppdata memory

10、page initalizationPPAGEENABLE EQU 0 ; set to 1 if ppdata object are used.; PPAGE number ; uppermost 256-byte address of the page used for ppdata variables.PPAGE EQU 0; SFR address which supplies uppermost address byte ; most 8051 variants use P2 as uppermost address bytePPAGE_SFR DATA 0A0H; ;-; Stan

11、dard SFR Symbols ACC DATA 0E0HB DATA 0F0HSP DATA 81HDPL DATA 82HDPH DATA 83H NAME ?C_STARTUPPUBLIC OSStack PUBLIC OSStkStart?C_C51STARTUP SEGMENT CODE?STACK SEGMENT IDATA RSEG ?STACKOSStack:DS 50HOSStkStart IDATA OSStack-1 EXTRN CODE (?C_START) PUBLIC ?C_STARTUP CSEG AT 0?C_STARTUP: LJMP STARTUP1 RS

12、EG ?C_C51STARTUPSTARTUP1:IF IDATALEN 0 MOV R0,#IDATALEN - 1 CLR AIDATALOOP: MOV R0,A DJNZ R0,IDATALOOPENDIFIF XDATALEN 0 MOV DPTR,#XDATASTART MOV R7,#LOW (XDATALEN) IF (LOW (XDATALEN) 0 MOV R6,#(HIGH (XDATALEN) +1 ELSE MOV R6,#HIGH (XDATALEN) ENDIF CLR AXDATALOOP: MOVX DPTR,A INC DPTR DJNZ R7,XDATAL

13、OOP DJNZ R6,XDATALOOPENDIFIF PPAGEENABLE 0 MOV PPAGE_SFR,#PPAGEENDIFIF PDATALEN 0 MOV R0,#LOW (PDATASTART) MOV R7,#LOW (PDATALEN) CLR APDATALOOP: MOVX R0,A INC R0 DJNZ R7,PDATALOOPENDIFIF IBPSTACK 0EXTRN DATA (?C_IBP) MOV ?C_IBP,#LOW IBPSTACKTOPENDIFIF XBPSTACK 0EXTRN DATA (?C_XBP) MOV ?C_XBP,#HIGH

14、XBPSTACKTOP MOV ?C_XBP+1,#LOW XBPSTACKTOPENDIFIF PBPSTACK 0EXTRN DATA (?C_PBP) MOV ?C_PBP,#LOW PBPSTACKTOPENDIF MOV SP,#?STACK-1; This code is required if you use L51_BANK.A51 with Banking Mode 4; Code Banking; Select Bank 0 for L51_BANK.A51 Mode 4#if 0 ; Initialize bank mechanism to code bank 0 whe

15、n using L51_BANK.A51 with Banking Mode 4.EXTRN CODE (?B_SWITCH0) CALL ?B_SWITCH0 ; init bank mechanism to code bank 0#endif; LJMP ?C_START END修改添加文件2:OS_CPU_A.ASM$NOMOD51NAME OS_CPU_A ;EA BIT 0A8H.7TR0 BIT 088H.4TH0 DATA 08CHTL0 DATA 08AHET0 BIT 0A8H.1?PR?OSStartHighRdy?OS_CPU_A SEGMENT CODE?PR?OSCt

16、xSw?OS_CPU_A SEGMENT CODE?PR?OSIntCtxSw?OS_CPU_A SEGMENT CODE?PR?OSTickISR?OS_CPU_A SEGMENT CODE?PR?_?serial?OS_CPU_A SEGMENT CODEEXTRN IDATA (OSTCBCur)EXTRN IDATA (OSTCBHighRdy)EXTRN IDATA (OSRunning)EXTRN IDATA (OSPrioCur)EXTRN IDATA (OSPrioHighRdy)EXTRN CODE (_?OSTaskSwHook)EXTRN CODE (_?OSIntEnt

17、er)EXTRN CODE (_?OSIntExit)EXTRN CODE (_?OSTimeTick)EXTRN CODE (_?serial)EXTRNDATA (?C_XBP)EXTRNIDATA (OSStack)EXTRNIDATA (OSStkStart)PUBLIC OSStartHighRdyPUBLIC OSCtxSwPUBLIC OSIntCtxSwPUBLIC OSTickISRPUBLIC SerialISR;?STACK SEGMENT IDATA;RSEG ?STACK;OSStack:;DS 50H;OSStkStart IDATA OSStack-1PUSHAL

18、L MACROPUSH PSWPUSH ACCPUSH BPUSH DPLPUSH DPHMOV A,R0 ;R0-R7PUSH ACCMOV A,R1PUSH ACCMOV A,R2PUSH ACCMOV A,R3PUSH ACCMOV A,R4PUSH ACCMOV A,R5PUSH ACCMOV A,R6PUSH ACCMOV A,R7PUSH ACCENDMPOPALL MACROPOP ACC ;R0-R7MOV R7,APOP ACCMOV R6,APOP ACCMOV R5,APOP ACCMOV R4,APOP ACCMOV R3,APOP ACCMOV R2,APOP ACC

19、MOV R1,APOP ACCMOV R0,APOP DPHPOP DPLPOP BPOP ACCPOP PSWENDM;-RSEG ?PR?OSStartHighRdy?OS_CPU_AOSStartHighRdy:USING 0 ;LCALL _?OSTaskSwHookOSCtxSw_in:;OSTCBCur = DPTRMOV R0,#LOW (OSTCBCur) INC R0MOV DPH,R0INC R0MOV DPL,R0;OSTCBCur-OSTCBStkPtr = DPTRINC DPTRMOVX A,DPTRMOV R0,AINC DPTRMOVX A,DPTRMOV R1

20、,AMOV DPH,R0MOV DPL,R1;*UserStkPtr = R5MOVX A,DPTRMOV R5,A ;MOV R0,#OSStkStartrestore_stack:INC DPTRINC R0MOVX A,DPTRMOV R0,ADJNZ R5,restore_stack;SPMOV SP,R0;?C_XBPINC DPTRMOVX A,DPTRMOV ?C_XBP,AINC DPTRMOVX A,DPTRMOV ?C_XBP+1,A;OSRunning=TRUEMOV R0,#LOW (OSRunning)MOV R0,#01POPALLSETB ET0SETB EARE

21、TI;-RSEG ?PR?OSCtxSw?OS_CPU_AOSCtxSw:PUSHALLOSIntCtxSw_in:;MOV A,SPCLR CSUBB A,#OSStkStartMOV R5,A ;OSTCBCur = DPTR MOV R0,#LOW (OSTCBCur) INC R0MOV DPH,R0 INC R0MOV DPL,R0;OSTCBCur-OSTCBStkPtr = DPTRINC DPTRMOVX A,DPTRMOV R0,AINC DPTRMOVX A,DPTRMOV R1,AMOV DPH,R0MOV DPL,R1;MOV A,R5MOVX DPTR,AMOV R0

22、,#OSStkStart ;save_stack:INC DPTRINC R0MOV A,R0MOVX DPTR,ADJNZ R5,save_stack;?C_XBPINC DPTRMOV A,?C_XBPMOVX DPTR,AINC DPTRMOV A,?C_XBP+1MOVX DPTR,ALCALL _?OSTaskSwHook;OSTCBCur = OSTCBHighRdyMOV R0,#OSTCBCurMOV R1,#OSTCBHighRdyMOV A,R1MOV R0,AINC R0INC R1MOV A,R1MOV R0,AINC R0INC R1MOV A,R1MOV R0,A;

23、OSPrioCur = OSPrioHighRdy ?,?MOV R0,#OSPrioCurMOV R1,#OSPrioHighRdyMOV A,R1MOV R0,ALJMP OSCtxSw_in;-RSEG ?PR?OSIntCtxSw?OS_CPU_AOSIntCtxSw:;SP=SP-4MOV A,SPCLR CSUBB A,#4MOV SP,ALJMP OSIntCtxSw_in;-CSEG AT 000BH ;OSTickISRLJMP OSTickISR ;RSEG ?PR?OSTickISR?OS_CPU_AOSTickISR:USING 0PUSHALLCLR TR0MOV T

24、H0,#70H ;?Tick=50?/?(?0.02?/?)MOV TL0,#00H ;OS_CPU_C.C ? OS_TICKS_PER_SECSETB TR0LCALL _?OSIntEnterLCALL _?OSTimeTickLCALL _?OSIntExitPOPALLRETICSEG AT 0023HLJMP SerialISRRSEG ?PR?_?serial?OS_CPU_ASerialISR:USING 0PUSHALLCLR EALCALL _?serialSETB EAPOPALLRETI;-END;-修改添加文件3:OS_CPU_C.c,添加修改部分红色字体标出#def

25、ine OS_CPU_GLOBALS#include includes.h/* OS INITIALIZATION HOOK* (BEGINNING)* Description: This function is called by OSInit() at the beginning of OSInit().* Arguments : none* Note(s) : 1) Interrupts should be disabled during this call.*/#if OS_CPU_HOOKS_EN 0 & OS_VERSION 203void OSInitHookBegin (voi

26、d)#endif/* OS INITIALIZATION HOOK* (END)* Description: This function is called by OSInit() at the end of OSInit().* Arguments : none* Note(s) : 1) Interrupts should be disabled during this call.*/#if OS_CPU_HOOKS_EN 0 & OS_VERSION 203void OSInitHookEnd (void)#endif/*$PAGE*/* TASK CREATION HOOK* Desc

27、ription: This function is called when a task is created.* Arguments : ptcb is a pointer to the task control block of the task being created.* Note(s) : 1) Interrupts are disabled during this call.*/#if OS_CPU_HOOKS_EN 0 void OSTaskCreateHook (OS_TCB *ptcb) ptcb = ptcb; /* Prevent compiler warning */

28、#endif/* TASK DELETION HOOK* Description: This function is called when a task is deleted.* Arguments : ptcb is a pointer to the task control block of the task being deleted.* Note(s) : 1) Interrupts are disabled during this call.*/#if OS_CPU_HOOKS_EN 0 void OSTaskDelHook (OS_TCB *ptcb) ptcb = ptcb;

29、/* Prevent compiler warning */#endif/* IDLE TASK HOOK* Description: This function is called by the idle task. This hook has been added to allow you to do * such things as STOP the CPU to conserve power.* Arguments : none* Note(s) : 1) Interrupts are enabled during this call.*/#if OS_CPU_HOOKS_EN 0 &

30、 OS_VERSION = 251void OSTaskIdleHook (void)#endif/* STATISTIC TASK HOOK* Description: This function is called every second by uC/OS-IIs statistics task. This allows your * application to add functionality to the statistics task.* Arguments : none*/#if OS_CPU_HOOKS_EN 0 void OSTaskStatHook (void)#end

31、if/*$PAGE*/* INITIALIZE A TASKS STACK* Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the* stack frame of the task being created. This function is highly processor specific.* Arguments : task is a pointer to the task code* pdata is a pointer to a use

32、r supplied data area that will be passed to the task* when the task first executes.* ptos is a pointer to the top of stack. It is assumed that ptos points to* a free entry on the task stack. If OS_STK_GROWTH is set to 1 then * ptos will contain the HIGHEST valid address of the stack. Similarly, if*

33、OS_STK_GROWTH is set to 0, the ptos will contains the LOWEST valid address* of the stack.* opt specifies options that can be used to alter the behavior of OSTaskStkInit().* (see uCOS_II.H for OS_TASK_OPT_?).* Returns : Always returns the location of the new top-of-stack once the processor registers

34、have* been placed on the stack in the proper order.* Note(s) : Interrupts are enabled when your task starts executing. You can change this by setting the* PSW to 0x0002 instead. In this case, interrupts would be disabled upon task startup. The* application code would be responsible for enabling inte

35、rrupts at the beginning of the task* code. You will need to modify OSTaskIdle() and OSTaskStat() so that they enable * interrupts. Failure to do this will make your system crash!*/OS_STK *OSTaskStkInit (void (*task)(void *pd), void *ppdata, OS_STK *ptos, INT16U opt) OS_STK *stk; opt = opt; /* opt is

36、 not used, prevent warning */ stk = (OS_STK *)ptos; /* Load stack pointer */ *stk+=15;/ *stk+ = (INT16U)task & 0xff;/8 *stk+ = (INT16U)task 8;/8 *stk+ = 0x00; /PSW *stk+ = 0x0a; /ACC *stk+ = 0x0b;/B *stk+ = 0x00; /DPL *stk+ = 0x00; /DPH *stk+ = 0x00; /R0 *stk+ = (INT16U)ppdata & 0xff; /R1 *stk+ = (I

37、NT16U)ppdata 8; /R2 *stk+ = 0x01; /R3 *stk+ = 0x04; /R4 *stk+ = 0x05; /R5 *stk+ = 0x06; /R6 *stk+ = 0x07;/R6*stk+ = (INT16U)(ptos+MaxStkSize) 8; /8 *stk+ = (INT16U)(ptos+MaxStkSize) & 0xff;/8 return (OS_STK *)ptos);/*$PAGE*/* INITIALIZE A TASKS STACK FOR FLOATING POINT EMULATION* Description: This f

38、unction MUST be called BEFORE calling either OSTaskCreate() or OSTaskCreateExt() in* order to initialize the tasks stack to allow the task to use the Borland floating-point * emulation. The returned pointer MUST be used in the task creation call.* Ex.: OS_STK TaskStk1000;* void main (void)* * OS_STK

39、 *ptos;* OS_STK *pbos;* INT32U size;* OSInit();* .* .* ptos = &TaskStk999;* pbos = &TaskStk0;* psize = 1000;* OSTaskStkInit_FPE_x86(&ptos, &pbos, &size);* OSTaskCreate(Task, (void *)0, ptos, 10);* .* .* OSStart();* * Arguments : pptos is the pointer to the tasks top-of-stack pointer which would be p

40、assed to * OSTaskCreate() or OSTaskCreateExt().* ppbos is the pointer to the new bottom of stack pointer which would be passed to* OSTaskCreateExt().* psize is a pointer to the size of the stack (in number of stack elements). You * MUST allocate sufficient stack space to leave at least 384 bytes for the * floating-point emulation.* Returns : The new size of the stack

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!