Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > e677bbbdff6d27fe001f15e0ef2bb4cc > files > 239

sdcc-3.0.0-0.fc14.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2008 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>3.10.2 Enabling and Disabling Interrupts directly</TITLE>
<META NAME="description" CONTENT="3.10.2 Enabling and Disabling Interrupts directly">
<META NAME="keywords" CONTENT="sdccman">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="sdccman.css">

<LINK REL="next" HREF="node75.html">
<LINK REL="previous" HREF="node73.html">
<LINK REL="up" HREF="node72.html">
<LINK REL="next" HREF="node75.html">
</HEAD>

<BODY >
<!--Navigation Panel-->
<A NAME="tex2html1793"
  HREF="node75.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1787"
  HREF="node72.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1781"
  HREF="node73.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1789"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1791"
  HREF="node191.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1794"
  HREF="node75.html">3.10.3 Semaphore locking (mcs51/ds390)</A>
<B> Up:</B> <A NAME="tex2html1788"
  HREF="node72.html">3.10 Enabling and Disabling</A>
<B> Previous:</B> <A NAME="tex2html1782"
  HREF="node73.html">3.10.1 Critical Functions and</A>
 &nbsp; <B>  <A NAME="tex2html1790"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1792"
  HREF="node191.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION004102000000000000000">
3.10.2 Enabling and Disabling Interrupts directly</A>
</H2>

<P>
Interrupts<A NAME="1781"></A> can also be disabled and enabled directly
(8051):
<BLOCKQUOTE>
<TT>EA = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EA_SAVE
= EA;</TT>
</BLOCKQUOTE>
<P>
<BLOCKQUOTE><TT>...&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;&nbsp;&nbsp;&nbsp;&nbsp;EA
= 0;</TT>
</BLOCKQUOTE>
<P>
<BLOCKQUOTE><TT>EA = 1;&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;...</TT>
</BLOCKQUOTE>
<P>
<BLOCKQUOTE><TT>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EA
= EA_SAVE;</TT>

</BLOCKQUOTE>
On other architectures which have separate opcodes for enabling and
disabling interrupts you might want to make use of defines with inline
assembly<A NAME="1788"></A> (HC08<A NAME="1789"></A>):
<BLOCKQUOTE>
<TT>#define CLI __asm<A NAME="1791"></A>&nbsp;&nbsp;cli&nbsp;&nbsp;__endasm<A NAME="1792"></A>; </TT>
</BLOCKQUOTE>
<P>
<BLOCKQUOTE><TT>#define SEI __asm&nbsp;&nbsp;sei&nbsp;&nbsp;__endasm; </TT>
</BLOCKQUOTE>
<P>
<BLOCKQUOTE><TT>...</TT>

</BLOCKQUOTE>
Note: it is sometimes sufficient to disable only a specific interrupt
source like f.e. a timer or serial interrupt by manipulating an <I>interrupt
mask<A NAME="1796"></A></I> register. 

<P>
Usually the time during which interrupts are disabled should be kept
as short as possible. This minimizes both <I>interrupt latency</I><A NAME="1798"></A>
(the time between the occurrence of the interrupt and the execution
of the first code in the interrupt routine) and <I>interrupt jitter</I><A NAME="1800"></A>
(the difference between the shortest and the longest interrupt latency).
These really are something different, f.e. a serial interrupt has
to be served before its buffer overruns so it cares for the maximum
interrupt latency, whereas it does not care about jitter. On a loudspeaker
driven via a digital to analog converter which is fed by an interrupt
a latency of a few milliseconds might be tolerable, whereas a much
smaller jitter will be very audible.

<P>
You can reenable interrupts within an interrupt routine and on some
architectures you can make use of two (or more) levels of <I>interrupt
priorities</I><A NAME="1802"></A>. On some architectures which
don't support interrupt priorities these can be implemented by manipulating
the interrupt mask and reenabling interrupts within the interrupt
routine. Check there is sufficient space on the stack<A NAME="1803"></A>
and don't add complexity unless you have to. 

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1793"
  HREF="node75.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1787"
  HREF="node72.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1781"
  HREF="node73.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1789"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html1791"
  HREF="node191.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1794"
  HREF="node75.html">3.10.3 Semaphore locking (mcs51/ds390)</A>
<B> Up:</B> <A NAME="tex2html1788"
  HREF="node72.html">3.10 Enabling and Disabling</A>
<B> Previous:</B> <A NAME="tex2html1782"
  HREF="node73.html">3.10.1 Critical Functions and</A>
 &nbsp; <B>  <A NAME="tex2html1790"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html1792"
  HREF="node191.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>

2011-03-20
</ADDRESS>
</BODY>
</HTML>