DM5816/DM6816
RTD Embedded Technologies, Inc.
36
not use any DOS functions or routines that call DOS functions from within an ISR
. DOS is
not
reentrant; that is, a DOS function cannot call itself. In typical programming, this will not
happen because of the way DOS is written. But what about when using interrupts? Then, you
could have a situation such as this in your program. If DOS function X is being executed when
an interrupt occurs and the interrupt routine makes a call to DOS function X, then function X is
essentially being called while it is already active. Such a reentrancy attempt spells disaster
because DOS functions are not written to support it. This is a complex concept and you do not
need to understand it. Just make sure that you do not call any DOS functions from within your
ISR. The one wrinkle is that, unfortunately, it is not obvious which library routines included with
your compiler use DOS functions. A rule of thumb is that routines which write to the screen, or
check the status of or read the keyboard, and any disk I/O routines use DOS and should be
avoided in your ISR.
The same problem of reentrancy exists for many floating point emulators as well, meaning you
may have to avoid floating point (real) math in your ISR.
Note that the problem of reentrancy exists, no matter what programming language you are
using. Even if you are writing your ISR in assembly language, DOS and many floating point
emulators are not reentrant. Of course, there are ways around this problem, such as those
which involve checking to see if any DOS functions are currently active when your ISR is
called, but such solutions are well beyond the scope of this discussion.
The second major concern when writing your ISR is to make it as short as possible in terms of
execution time. Spending long periods of time in your ISR may mean that other important
interrupts are being ignored. Also, if you spend too long in your ISR, it may be called again
before you have completed handling the first run. This often leads to a hang that requires a
reboot.
Your ISR should have this structure:
•
Push any processor registers used in your ISR. Most C and Pascal interrupt routines
automatically do this for you.
•
Put the body of your routine here.
•
Clear the interrupt status flag.
•
Issue the EOI command to the 8259 interrupt controller by writing 20H to port 20H.
•
Pop all registers pushed on entrance. Most C and Pascal interrupt routines
automatically do this for you. The following C and Pascal examples show what the
shell of your ISR should be like. Only the clear interrupt command sequence for the
source which caused the interrupt needs to be included:
The following C and Pascal examples show what the shell of your ISR should be like. Only the
clear interrupt command sequence for the source which caused the interrupt needs to be
included.
In C:
void interrupt ISR(void)
{
/* Your code goes here.
Do not
use any DOS functions! */
Summary of Contents for DM5816
Page 1: ...BDM 610010027 Rev A DM5816 DM6816 Triggered User s Manual...
Page 7: ...DM5816 DM6816 RTD Embedded Technologies Inc 7...
Page 15: ...DM5816 DM6816 RTD Embedded Technologies Inc 15 Fig 1 7 Base Address Switch S1...
Page 22: ...DM5816 DM6816 RTD Embedded Technologies Inc 22...
Page 42: ...DM5816 DM6816 RTD Embedded Technologies Inc 42 P3 Connector P6 Connector...