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

📄 micrium1.htm

📁 网上下载的一些心得集 网友交流之经验谈 uCOS51移植心得 uCOS-II 在 ARM7 上的移植
💻 HTM
📖 第 1 页 / 共 2 页
字号:
        <TR>
          <TD width="100%" bgColor=#c0c0c0>
            <P align=left><BIG><STRONG>FAQ-03: Where should I enable the 'tick' 
            interrupt?</STRONG></BIG><A 
      name=FAQ-03></A></P></TD></TR></TBODY></TABLE></BIG></BIG>
      <P align=left><FONT size=4>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.</FONT></P>
      <P align=left><A 
      href="http://www.ucos-ii.com/contents/support/faqs-test1.html#TOP"><IMG 
      height=30 src="" width=67 border=0></A></P>
      <P align=left>&nbsp;</P><BIG><BIG>
      <TABLE width="100%" border=1>
        <TBODY>
        <TR>
          <TD width="100%" bgColor=#c0c0c0>
            <P align=left><STRONG><BIG>FAQ-04: Does 礐/OS and 礐/OS-II work with 
            Microsoft C/C++?<A 
      name=FAQ-04></A></BIG></STRONG></P></TD></TR></TBODY></TABLE></BIG></BIG>
      <P align=left><FONT size=4>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.</FONT></P>
      <P align=left><FONT size=4>See also </FONT><A 
      href="http://www.ucos-ii.com/contents/support/faqs-test1.html#FAQ-06"><B><FONT 
      color=#ff0000 size=5>FAQ-06</FONT></B></A><FONT size=4>.<BR></FONT></P>
      <P align=left><A 
      href="http://www.ucos-ii.com/contents/support/faqs-test1.html#TOP"><IMG 
      height=30 src="" width=67 border=0></A></P>
      <P align=left>&nbsp;</P><BIG><BIG>
      <TABLE width="100%" border=1>
        <TBODY>
        <TR>
          <TD width="100%" bgColor=#c0c0c0>
            <P align=left><STRONG><BIG>FAQ-05: Are there other ports available 
            for 礐/OS and 礐/OS-II?<A 
        name=FAQ-05></A></BIG></STRONG></P></TD></TR></TBODY></TABLE></BIG></BIG>
      <P align=left><FONT size=4>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><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. </FONT>
      <P align=left><A 
      href="http://www.ucos-ii.com/contents/support/faqs-test1.html#TOP"><IMG 
      height=30 src="" width=67 border=0></A> 
      <P align=left><A 
      href="http://www.ucos-ii.com/contents/support/faqs-test1.html#TOP"><BR></A><BIG><BIG>
      <TABLE width="100%" border=1>
        <TBODY>
        <TR>
          <TD width="100%" bgColor=#c0c0c0>
            <P align=left><STRONG><BIG>FAQ-06: Is there a better way to 
            implement OSIntCtxSw() and ISRs?<A 
            name=FAQ-06></A></BIG></STRONG></P></TD></TR></TBODY></TABLE></BIG></BIG>
      <P align=left><FONT size=4>As you probably know, 礐/OS-II has a function 
      that is dependent on compiler options (<FONT 
      face="Courier New">OSIntCtxSw()</FONT>) and, the port designer HAS to 
      adjust the Stack Pointer based on the code generation of the compiler. 
      </FONT></P>
      <P align=left><FONT size=4>On certain processors (e.g. 80x86) you can 
      </FONT><FONT size=4>simply write ISRs so that you SAVE the Stack Pointer 
      (<FONT face="Courier New">SS:SP</FONT> for the 80x86) into the current 
      task's <FONT face="Courier New">OS_TCB</FONT> after incrementing <FONT 
      face="Courier New">OSIntNesting</FONT>.&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 <FONT 
      face="Courier New">OSIntCtxSw()</FONT> to adjust the Stack Pointer (<FONT 
      face="Courier New">SP</FONT> for the 80x86) and the code to save the Stack 
      Pointer into the <FONT face="Courier New">OS_TCB</FONT>!</FONT></P>
      <P align=left><FONT size=4>The new pseudo code for an ISR and <FONT 
      face="Courier New">OSIntCtxSw()</FONT> is now:</FONT></P>
      <P><FONT face="Courier New" size=2>MyISR:<BR>&nbsp;&nbsp;&nbsp; Save ALL 
      registers;<BR>&nbsp;&nbsp;&nbsp; OSIntNesting++;<BR></FONT><FONT 
      face="Courier New">&nbsp;&nbsp; </FONT><FONT face="Courier New"><FONT 
      size=2>OSTCBCur-&gt;OSTCBStkPtr = SP;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &lt;&lt;&lt;&lt; NEW<BR></FONT></FONT><FONT face="Courier New" 
      size=2>&nbsp;&nbsp;&nbsp; /* Handle ISR */<BR>&nbsp;&nbsp;&nbsp; 
      OSIntExit();<BR>&nbsp;&nbsp;&nbsp; Restore ALL 
      registers;<BR>&nbsp;&nbsp;&nbsp; Return from Interrupt;</FONT></P>
      <P><FONT face="Courier New" size=2>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;</FONT></P>
      <P align=left><FONT size=4>In assembly language for the 80x86 (Large 
      model), this becomes:</FONT></P><FONT size=2>
      <P><FONT face="Courier New">_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</FONT></P>
      <P>&nbsp;</P>
      <P><FONT face="Courier New" size=2>_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</FONT></P></FONT>
      <P></P>
      <P>

⌨️ 快捷键说明

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