Title: Using The Status Register With Xtreme/104 and DFlex
Keywords: Status Register, DFlex, Xtreme
Date: August 2, 2002
The status port is a collection of all the INT signals from the UARTS. Data bit-0 is INT1, bit-1 is INT2, and so on up to bit-7 which is INT8.
The status port bits should reflect the state of all the INT signals. They are active high. An INT signal for any given port will NOT go inactive until ALL the interrupt “reasons” for that port have been processed. The ISR register (offset 2) must be read before any other register (when servicing an interrupt), or the INT signal will never operate as expected.
When using the INT status port, the sequence of code should be as follows:
Assuming an Intial State when all ports are inactive and the status port reads 0x00.
- INTerrupt occurs.
- Read Status port (obtain value “S”).
- For each bit set in “S” (scanned by whatever algorithm… sequential, or last port first, or most often used first, or whatever…as long as all bits are checked):
- Read the ISR register of the appropriate port (obtain value “R”).
- Take action appropriate for the “R” value obtained
- Repeat step 2 and 3 until S becomes 0x00.
- Exit handler.
Here’s the pseudo-code
S = status_port;
if (S == 0) // optional, bit is a fast way to exit when S== 0
for (i=0; i<8; i++) // sequential scan
if (S & (1 << i))
R = ISR_register[i]; // some other code may be appropriate to select the port…pointers etc.
switch (R) // or some other selection method
} while (S != 0);
End of KDB-285