⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faqs.htm

📁 网上下载的一些心得集 网友交流之经验谈 uCOS51移植心得 uCOS-II 在 ARM7 上的移植
💻 HTM
📖 第 1 页 / 共 2 页
字号:
          <TD class=title>F<A name=faq3></A>AQ-03: Where should I enable the 
            'tick' interrupt?</TD></TR></TBODY></TABLE>
      <P>You should enable the tick interrupt AFTER you have started 礐/OS (or 
      礐/OS-II) in a 'startup' task as shown in the example code provided with 
      the book. This way, the OS is in a state ready to accept interrupts and 
      can thus process interrupts.</P>
      <P class=codewiew></P>
      <P></P>
      <P><A href="http://ucos-ii.com/contents/support/faqs.html#top"><IMG 
      height=18 alt="Back to top" src="faqs.files/backtotop.gif" width=84 
      border=0 name=top></A></P>
      <P>&nbsp;</P>
      <TABLE cellSpacing=0 cellPadding=3 width="100%" bgColor=#ced6f0 
        border=0><TBODY>
        <TR>
          <TD class=title>F<A name=faq4></A>AQ-04: Does 礐/OS and 礐/OS-II 
            work with Microsoft C/C++?</TD></TR></TBODY></TABLE>
      <P>Yes, you will have to adjust the SP offset constant (see item 1)) and 
      disable stack checking. Others have used the Microsoft compiler without 
      too many problems.<BR>See also <A 
      href="http://ucos-ii.com/contents/support/faqs.html#faq6">FAQ-06</A>.</P>
      <P class=codewiew></P>
      <P></P>
      <P><A href="http://ucos-ii.com/contents/support/faqs.html#top"><IMG 
      height=18 alt="Back to top" src="faqs.files/backtotop.gif" width=84 
      border=0 name=top></A><BR>&nbsp;</P>
      <TABLE cellSpacing=0 cellPadding=3 width="100%" bgColor=#ced6f0 
        border=0><TBODY>
        <TR>
          <TD class=title>F<A name=faq5></A>AQ-05: Are there other ports 
            available for 礐/OS and 礐/OS-II?</TD></TR></TBODY></TABLE>
      <P>There are currently a large number of ports available for 礐/OS and 
      礐/OS-II.&nbsp; I am planning on making a number of ports available on 
      this WEB site as they become available.&nbsp; <BR>A port to 礐/OS can 
      easily be ported to 礐/OS-II in about an hour or so.&nbsp; This assumes 
      that you are familiar with the target processor and it's compiler.&nbsp; 
      This means that if a port for 礐/OS-II is not currently available but a 
      port for 礐/OS exist then you could modify the 礐/OS port to work with 
      礐/OS-II.&nbsp; Chapter 10 in the book (礐/OS-II) describes the steps. 
</P>
      <P class=codewiew></P>
      <P></P>
      <P><A href="http://ucos-ii.com/contents/support/faqs.html#top"><IMG 
      height=18 alt="Back to top" src="faqs.files/backtotop.gif" width=84 
      border=0 name=top></A><BR>&nbsp;</P>
      <TABLE cellSpacing=0 cellPadding=3 width="100%" bgColor=#ced6f0 
        border=0><TBODY>
        <TR>
          <TD class=title>F<A name=faq6></A>AQ-06: Is there a better way to 
            implement OSIntCtxSw() and ISRs?</TD></TR></TBODY></TABLE>
      <P>As you probably know, 礐/OS-II has a function that is dependent on 
      compiler options <SPAN class=codewiew>(OSIntCtxSw())</SPAN> and, the port 
      designer HAS to adjust the Stack Pointer based on the code generation of 
      the compiler. </P>
      <P>On certain processors (e.g. 80x86) you can simply write ISRs so that 
      you SAVE the Stack Pointer (SS:SP for the 80x86) into the current task's 
      <SPAN class=codewiew>OS_TCB</SPAN> after incrementing <SPAN 
      class=codewiew>OSIntNesting</SPAN>.&nbsp; This way, we save the PROPER 
      pointer to the ISR stack frame in case we don't actually return to the 
      interrupted task.&nbsp; If we DO return to the interrupted task then, 
      there is no harm and all we did was waste a little bit of CPU time!&nbsp; 
      Of course, we eliminate the code at the beginning of <SPAN 
      class=codewiew>OSIntCtxSw()</SPAN> to adjust the Stack Pointer (SP for the 
      80x86) and the code to save the Stack Pointer into the <SPAN 
      class=codewiew>OS_TCB</SPAN>!</P>
      <P>The new pseudo code for an ISR and <SPAN 
      class=codewiew>OSIntCtxSw()</SPAN> is now:</P>
      <P><SPAN class=codewiew>MyISR:<BR>&nbsp;&nbsp;&nbsp; Save ALL 
      registers;<BR>&nbsp;&nbsp;&nbsp; OSIntNesting++;<BR>&nbsp;&nbsp; 
      OSTCBCur-&gt;OSTCBStkPtr = SP;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;&lt;&lt;&lt; NEW<BR>&nbsp;&nbsp;&nbsp; /* Handle ISR 
      */<BR>&nbsp;&nbsp;&nbsp; OSIntExit();<BR>&nbsp;&nbsp;&nbsp; Restore ALL 
      registers;<BR>&nbsp;&nbsp;&nbsp; Return from 
      Interrupt;<BR>OSIntCtxSw:<BR>&nbsp;&nbsp;&nbsp; 
      OSTaskSwHook();<BR>&nbsp;&nbsp;&nbsp; OSTCBCur = 
      OSTCBHighRdy;<BR>&nbsp;&nbsp;&nbsp; SP = 
      OSTCBHighRdy-&gt;OSTCBStkPtr;<BR>&nbsp;&nbsp;&nbsp; Restore ALL 
      registers;<BR>&nbsp;&nbsp;&nbsp; Return from Interrupt;</SPAN></P>
      <P>In assembly language for the 80x86 (Large model), this becomes:</P>
      <P class=codewiew>_MyISR PROC FAR<BR>;<BR>&nbsp;&nbsp;&nbsp; 
      PUSHA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      ; Save interrupted task's context<BR>&nbsp;&nbsp;&nbsp; PUSH 
      ES<BR>&nbsp;&nbsp;&nbsp; PUSH DS<BR>;<BR>&nbsp;&nbsp;&nbsp; MOV AX, 
      SEG(_OSIntNesting)&nbsp;&nbsp;&nbsp;&nbsp; ; Reload 
      DS<BR>&nbsp;&nbsp;&nbsp; MOV DS, AX<BR>&nbsp;&nbsp;&nbsp; INC BYTE PTR 
      _OSIntNesting&nbsp;&nbsp;&nbsp;&nbsp; ; Notify uC/OS-II of 
      ISR<BR>;<BR>&nbsp;&nbsp;&nbsp; LES BX, DWORD PTR DS:_OSTCBCur ; 
      OSTCBCur-&gt;OSTCBStkPtr = SS:SP<BR>&nbsp;&nbsp;&nbsp; MOV ES:[BX+2], 
      SS<BR>&nbsp;&nbsp;&nbsp; MOV ES:[BX+0], SP<BR>&nbsp;&nbsp;&nbsp; CALL FAR 
      PTR _MyISRHandler&nbsp;&nbsp;&nbsp;&nbsp; ; Process the 
      Interrupt<BR>;<BR>&nbsp;&nbsp;&nbsp; CALL FAR PTR 
      _OSIntExit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Notify uC/OS-II of 
      end of ISR<BR>;<BR>&nbsp;&nbsp;&nbsp; POP 
      DS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      ; Restore interrupted task's context<BR>&nbsp;&nbsp;&nbsp; POP 
      ES<BR>&nbsp;&nbsp;&nbsp; POPA<BR>;<BR>&nbsp;&nbsp;&nbsp; 
      IRET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      ; Return to interrupted task<BR>;<BR>_MyISR ENDP<BR>&nbsp;<BR>_OSIntCtxSw 
      PROC FAR<BR>;<BR>&nbsp;&nbsp;&nbsp; CALL FAR PTR 
      _OSTaskSwHook&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Call user defined task 
      switch hook<BR>;<BR>&nbsp;&nbsp;&nbsp; MOV AX, WORD PTR DS:_OSTCBHighRdy+2 
      ; OSTCBCur = OSTCBHighRdy<BR>&nbsp;&nbsp;&nbsp; MOV DX, WORD PTR 
      DS:_OSTCBHighRdy <BR>&nbsp;&nbsp;&nbsp; MOV WORD PTR DS:_OSTCBCur+2, 
      AX<BR>&nbsp;&nbsp;&nbsp; MOV WORD PTR DS:_OSTCBCur, DX 
      <BR>;<BR>&nbsp;&nbsp;&nbsp; MOV AL, BYTE PTR DS:_OSPrioHighRdy ; OSPrioCur 
      = OSPrioHighRdy<BR>&nbsp;&nbsp;&nbsp; MOV BYTE PTR DS:_OSPrioCur, 
      AL<BR>;<BR>&nbsp;&nbsp;&nbsp; LES BX, DWORD PTR DS:_OSTCBHighRdy ; SS:SP = 
      OSTCBHighRdy-&gt;OSTCBStkPtr<BR>&nbsp;&nbsp;&nbsp; MOV SS, 
      ES:[BX+2]<BR>&nbsp;&nbsp;&nbsp; MOV SP, ES:[BX]<BR>;<BR>&nbsp;&nbsp;&nbsp; 
      POP 
      DS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      ; Load new task's context<BR>&nbsp;&nbsp;&nbsp; POP 
      ES<BR>&nbsp;&nbsp;&nbsp; POPA<BR>;<BR>&nbsp;&nbsp;&nbsp; 
      IRET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      ; Return to new task<BR>;<BR>_OSIntCtxSw ENDP</P>
      <P class=codewiew></P>
      <P></P>
      <P><A href="http://ucos-ii.com/contents/support/faqs.html#top"><IMG 
      height=18 alt="Back to top" src="faqs.files/backtotop.gif" width=84 
      border=0 name=top></A><BR>&nbsp;</P>
      <P>&nbsp;</P>
      <P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -