?? faqs.htm
字號:
<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> </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> </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. I am planning on making a number of ports available on
this WEB site as they become available. <BR>A port to 礐/OS can
easily be ported to 礐/OS-II in about an hour or so. This assumes
that you are familiar with the target processor and it's compiler.
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. 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> </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>. This way, we save the PROPER
pointer to the ISR stack frame in case we don't actually return to the
interrupted task. 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!
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> Save ALL
registers;<BR> OSIntNesting++;<BR>
OSTCBCur->OSTCBStkPtr = SP;
<<<< NEW<BR> /* Handle ISR
*/<BR> OSIntExit();<BR> Restore ALL
registers;<BR> Return from
Interrupt;<BR>OSIntCtxSw:<BR>
OSTaskSwHook();<BR> OSTCBCur =
OSTCBHighRdy;<BR> SP =
OSTCBHighRdy->OSTCBStkPtr;<BR> Restore ALL
registers;<BR> 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>
PUSHA
; Save interrupted task's context<BR> PUSH
ES<BR> PUSH DS<BR>;<BR> MOV AX,
SEG(_OSIntNesting) ; Reload
DS<BR> MOV DS, AX<BR> INC BYTE PTR
_OSIntNesting ; Notify uC/OS-II of
ISR<BR>;<BR> LES BX, DWORD PTR DS:_OSTCBCur ;
OSTCBCur->OSTCBStkPtr = SS:SP<BR> MOV ES:[BX+2],
SS<BR> MOV ES:[BX+0], SP<BR> CALL FAR
PTR _MyISRHandler ; Process the
Interrupt<BR>;<BR> CALL FAR PTR
_OSIntExit ; Notify uC/OS-II of
end of ISR<BR>;<BR> POP
DS
; Restore interrupted task's context<BR> POP
ES<BR> POPA<BR>;<BR>
IRET
; Return to interrupted task<BR>;<BR>_MyISR ENDP<BR> <BR>_OSIntCtxSw
PROC FAR<BR>;<BR> CALL FAR PTR
_OSTaskSwHook ; Call user defined task
switch hook<BR>;<BR> MOV AX, WORD PTR DS:_OSTCBHighRdy+2
; OSTCBCur = OSTCBHighRdy<BR> MOV DX, WORD PTR
DS:_OSTCBHighRdy <BR> MOV WORD PTR DS:_OSTCBCur+2,
AX<BR> MOV WORD PTR DS:_OSTCBCur, DX
<BR>;<BR> MOV AL, BYTE PTR DS:_OSPrioHighRdy ; OSPrioCur
= OSPrioHighRdy<BR> MOV BYTE PTR DS:_OSPrioCur,
AL<BR>;<BR> LES BX, DWORD PTR DS:_OSTCBHighRdy ; SS:SP =
OSTCBHighRdy->OSTCBStkPtr<BR> MOV SS,
ES:[BX+2]<BR> MOV SP, ES:[BX]<BR>;<BR>
POP
DS
; Load new task's context<BR> POP
ES<BR> POPA<BR>;<BR>
IRET
; 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> </P>
<P> </P>
<P>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -