[其他MCU] Freescale XS128移植uCOSii汇编部分出现问题

[复制链接]
 楼主| lcr52099 发表于 2015-12-5 23:32 | 显示全部楼层 |阅读模式
  1. #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
  2. OS_CPU_SR  OSCPUSaveSR(void);
  3. void       OSCPURestoreSR(OS_CPU_SR cpu_sr);
  4. #endif

  1. #define  OS_CRITICAL_METHOD    3

  2. #if      OS_CRITICAL_METHOD == 1
  3. #define  OS_ENTER_CRITICAL()  asm  ("CLI")                    /* Disable interrupts                        */
  4. #define  OS_EXIT_CRITICAL()   asm  ("STI")                    /* Enable  interrupts                        */
  5. #endif

  6. #if      OS_CRITICAL_METHOD == 2
  7. #define  OS_ENTER_CRITICAL()  asm ("PUSHF; CLI")            /* Disable interrupts                        */
  8. #define  OS_EXIT_CRITICAL()   asm  ("POPF")                   /* Enable  interrupts                        */
  9. #endif

  10. #if      OS_CRITICAL_METHOD == 3
  11. #define  OS_ENTER_CRITICAL()  (cpu_sr = OSCPUSaveSR())    /* Disable interrupts                        */
  12. #define  OS_EXIT_CRITICAL()   (OSCPURestoreSR(cpu_sr))    /* Enable  interrupts                        */
  13. #endif
  1. <blockquote>OS_CPU_SR_Save:
编译后报错 Symbol OSCPUSaveSR in file ***************\OS_CORE.c.o is undefined
                  Symbol OSCPURestore in file ***************\OS_CORE.c.o is undefined
                   Link failed




还有一个警告
指向interrupt VectorNumber_Vpit0 void PIT_ISR(void) ,
other segment than in previous declaration
不知道是哪里出问题了 求大神指点
新人只有八分
  1. #pragma CODE_SEG __NEAR_SEG NON_BANKED

  2. interrupt VectorNumber_Vpit0 void PIT_ISR(void){   
  3.     EnableInterrupts;
  4.       
  5.     PITTF_PTF0=1;
  6.    
  7.    
  8.     OSTickISR_Handler();

  9.             
  10.            
  11.         
  12. }

 楼主| lcr52099 发表于 2015-12-5 23:34 | 显示全部楼层
好像汇编部分的代码没有粘贴完
  1. ;********************************************************************************************************
  2. ;                                               uC/OS-II
  3. ;                                         The Real-Time Kernel
  4. ;
  5. ;                         (c) Copyright 2002, Jean J. Labrosse, Weston, FL
  6. ;                                          All Rights Reserved
  7. ;
  8. ;
  9. ;                                       PAGED S12 Specific code
  10. ;                                            (METROWERKS)
  11. ;
  12. ; File         : OS_CPU_A.S
  13. ; By           : Eric Shufro
  14. ;
  15. ; Notes        : THIS FILE *MUST* BE LINKED INTO NON_BANKED MEMORY!
  16. ;********************************************************************************************************

  17. NON_BANKED:       section  

  18. ;********************************************************************************************************
  19. ;                                           I/O PORT ADDRESSES
  20. ;********************************************************************************************************

  21. PPAGE:            equ    $0015         ; Addres of PPAGE register (assuming MC9S12 (non XGATE part)

  22. ;********************************************************************************************************
  23. ;                                          PUBLIC DECLARATIONS
  24. ;********************************************************************************************************
  25.    
  26.     xdef   OS_CPU_SR_Save
  27.     xdef   OS_CPU_SR_Restore   
  28.     xdef   OSStartHighRdy
  29.     xdef   OSCtxSw
  30.     xdef   OSIntCtxSw
  31.     xdef   OSTickISR
  32.    
  33. ;********************************************************************************************************
  34. ;                                         EXTERNAL DECLARATIONS
  35. ;********************************************************************************************************
  36.    
  37.     xref   OSIntExit
  38.     xref   OSIntNesting  
  39.     xref   OSPrioCur   
  40.     xref   OSPrioHighRdy
  41.     xref   OSRunning   
  42.     xref   OSTaskSwHook
  43.     xref   OSTCBCur     
  44.     xref   OSTCBHighRdy
  45.     xref   OSTickISR_Handler
  46.     xref   OSTimeTick
  47.    
  48. ;********************************************************************************************************
  49. ;                                  SAVE THE CCR AND DISABLE INTERRUPTS
  50. ;                                                  &
  51. ;                                              RESTORE CCR
  52. ;
  53. ; Description : These function implements OS_CRITICAL_METHOD #3
  54. ;
  55. ; Arguments   : The function prototypes for the two functions are:
  56. ;               1) OS_CPU_SR  OSCPUSaveSR(void)
  57. ;                             where OS_CPU_SR is the contents of the CCR register prior to disabling
  58. ;                             interrupts.
  59. ;               2) void       OSCPURestoreSR(OS_CPU_SR os_cpu_sr);
  60. ;                             'os_cpu_sr' the the value of the CCR to restore.
  61. ;
  62. ; Note(s)     : 1) It's assumed that the compiler uses the D register to pass a single 16-bit argument
  63. ;                  to and from an assembly language function.
  64. ;********************************************************************************************************

  65. OS_CPU_SR_Save:
  66.     tfr  ccr,b                         ; It's assumed that 8-bit return value is in register B
  67.     sei                                ; Disable interrupts
  68.     rtc                                ; Return to caller with D containing the previous CCR

  69. OS_CPU_SR_Restore:
  70.     tfr  b,ccr                         ; B contains the CCR value to restore, move to CCR
  71.     rtc

  72. ;********************************************************************************************************
  73. ;                               START HIGHEST PRIORITY TASK READY-TO-RUN
  74. ;
  75. ; Description : This function is called by OSStart() to start the highest priority task that was created
  76. ;               by your application before calling OSStart().
  77. ;
  78. ; Arguments   : none
  79. ;
  80. ; Note(s)     : 1) The stack frame is assumed to look as follows:
  81. ;   
  82. ;                  OSTCBHighRdy->OSTCBStkPtr +  0       PPAGE
  83. ;                                            +  1       CCR
  84. ;                                            +  2       B
  85. ;                                            +  3       A
  86. ;                                            +  4       X (H)
  87. ;                                            +  5       X (L)
  88. ;                                            +  6       Y (H)
  89. ;                                            +  7       Y (L)
  90. ;                                            +  8       PC(H)
  91. ;                                            +  9       PC(L)
  92. ;
  93. ;               2) OSStartHighRdy() MUST:
  94. ;                      a) Call OSTaskSwHook() then,
  95. ;                      b) Set OSRunning to TRUE,
  96. ;                      c) Switch to the highest priority task by loading the stack pointer of the
  97. ;                         highest priority task into the SP register and execute an RTI instruction.
  98. ;********************************************************************************************************

  99. OSStartHighRdy:
  100.     call   OSTaskSwHook               ;  4~, Invoke user defined context switch hook            

  101.     ldab   #$01                        ;  2~, Indicate that we are multitasking
  102.     stab   OSRunning                  ;  4~                  

  103.     ldx    OSTCBHighRdy               ;  3~, Point to TCB of highest priority task ready to run
  104.     lds    0,x                         ;  3~, Load SP into 68HC12
  105.    
  106.     pula                               ;  3~, Get value of PPAGE register
  107.     staa   PPAGE                       ;  3~, Store into CPU's PPAGE register                                

  108.     rti                                ;  4~, Run task                                          

  109. ;********************************************************************************************************
  110. ;                                       TASK LEVEL CONTEXT SWITCH
  111. ;
  112. ; Description : This function is called when a task makes a higher priority task ready-to-run.
  113. ;
  114. ; Arguments   : none
  115. ;
  116. ; Note(s)     : 1) Upon entry,
  117. ;                  OSTCBCur     points to the OS_TCB of the task to suspend
  118. ;                  OSTCBHighRdy points to the OS_TCB of the task to resume
  119. ;
  120. ;               2) The stack frame of the task to suspend looks as follows:
  121. ;
  122. ;                  SP +  0       PC(H)
  123. ;                     +  1       PC(L)
  124. ;
  125. ;               3) The stack frame of the task to resume looks as follows:
  126. ;
  127. ;                  OSTCBHighRdy->OSTCBStkPtr +  0       PPAGE
  128. ;                                            +  1       CCR
  129. ;                                            +  2       B
  130. ;                                            +  3       A
  131. ;                                            +  4       X (H)
  132. ;                                            +  5       X (L)
  133. ;                                            +  6       Y (H)
  134. ;                                            +  7       Y (L)
  135. ;                                            +  8       PC(H)
  136. ;                                            +  9       PC(L)
  137. ;********************************************************************************************************

  138. OSCtxSw:
  139.     ldaa   PPAGE                       ;  3~, Get current value of PPAGE register                                
  140.     psha                               ;  2~, Push PPAGE register onto current task's stack

  141.     ldy    OSTCBCur                   ;  3~, OSTCBCur->OSTCBStkPtr = Stack Pointer     
  142.     sts    0,y                         ;  3~,                                          

  143.     call   OSTaskSwHook               ;  4~, Call user task switch hook                       
  144.    
  145.     ldx    OSTCBHighRdy               ;  3~, OSTCBCur  = OSTCBHighRdy
  146.     stx    OSTCBCur                   ;  3~                        
  147.    
  148.     ldab   OSPrioHighRdy              ;  3~, OSPrioCur = OSPrioHighRdy                        
  149.     stab   OSPrioCur                  ;  3~
  150.    
  151.     lds    0,x                         ;  3~, Load SP into 68HC12                              
  152.    
  153.     pula                               ;  3~, Get value of PPAGE register
  154.     staa   PPAGE                       ;  3~, Store into CPU's PPAGE register                                
  155.         
  156.     rti                                ;  8~, Run task                                         

  157. ;********************************************************************************************************
  158. ;                                    INTERRUPT LEVEL CONTEXT SWITCH
  159. ;
  160. ; Description : This function is called by OSIntExit() to perform a context switch to a task that has
  161. ;               been made ready-to-run by an ISR. The PPAGE register of the preempted task has already
  162. ;               been stacked during the start of the ISR that is currently running.
  163. ;
  164. ; Arguments   : none
  165. ;********************************************************************************************************

  166. OSIntCtxSw:
  167.     call   OSTaskSwHook               ;  4~, Call user task switch hook               

  168.     ldx    OSTCBHighRdy               ;  3~, OSTCBCur  = OSTCBHighRdy
  169.     stx    OSTCBCur                   ;  3~                        
  170.    
  171.     ldab   OSPrioHighRdy              ;  3~, OSPrioCur = OSPrioHighRdy                        
  172.     stab   OSPrioCur                  ;  3~
  173.    
  174.     lds    0,x                         ;  3~, Load the SP of the next task
  175.    
  176.     pula                               ;  3~, Get value of PPAGE register
  177.     staa   PPAGE                       ;  3~, Store into CPU's PPAGE register                                
  178.            
  179.     rti                                ;  8~, Run task                                 

  180. ;********************************************************************************************************
  181. ;                                           SYSTEM TICK ISR
  182. ;
  183. ; Description : This function is the ISR used to notify uC/OS-II that a system tick has occurred.  You
  184. ;               must setup the S12XE's interrupt vector table so that an OUTPUT COMPARE interrupt
  185. ;               vectors to this function.
  186. ;
  187. ; Arguments   : none
  188. ;
  189. ; Notes       :  1) The 'tick ISR' assumes the we are using the Output Compare specified by OS_TICK_OC
  190. ;                   (see APP_CFG.H and this file) to generate a tick that occurs every OS_TICK_OC_CNTS
  191. ;                   (see APP_CFG.H) which corresponds to the number of FRT (Free Running Timer)
  192. ;                   counts to the next interrupt.
  193. ;
  194. ;                2) All USER interrupts should be modeled EXACTLY like this where the only
  195. ;                   line to be modified is the call to your ISR_Handler and perhaps the call to
  196. ;                   the label name OSTickISR1.
  197. ;********************************************************************************************************

  198. OSTickISR:
  199.     ldaa   PPAGE                       ;  3~, Get current value of PPAGE register                                
  200.     psha                               ;  2~, Push PPAGE register onto current task's stack

  201.     inc    OSIntNesting                ;  4~, Notify uC/OS-II about ISR

  202.     ldab   OSIntNesting                ;  4~, if (OSIntNesting == 1) {   
  203.     cmpb   #$01                        ;  2~
  204.     bne    OSTickISR1                  ;  3~

  205.     ldy    OSTCBCur                    ;  3~,     OSTCBCur->OSTCBStkPtr = Stack Pointer     
  206.     sts    0,y                         ;  3~, }                                          

  207. OSTickISR1:
  208.     call   OSTickISR_Handler

  209. ;   cli                                ;  2~, Enable interrupts to allow interrupt nesting
  210.       
  211.     call   OSIntExit                   ;  6~+, Notify uC/OS-II about end of ISR
  212.    
  213.     pula                               ;  3~, Get value of PPAGE register
  214.     staa   PPAGE                       ;  3~, Store into CPU's PPAGE register                                
  215.         
  216.     rti                                ;  12~, Return from interrupt, no higher priority tasks ready.


这里的代码是网上找得 源程序编译能通过
神采奕奕 发表于 2015-12-6 13:53 | 显示全部楼层
学习!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

10

主题

26

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部