Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
8XC196Kx,8XC196Jx,87C196CA microcontroller family user's manual.1995.pdf
Скачиваний:
64
Добавлен:
23.08.2013
Размер:
3.97 Mб
Скачать

STANDARD AND PTS INTERRUPTS

5.5PROGRAMMING THE INTERRUPTS

The PTS select register (PTSSEL) selects either PTS service or a standard software interrupt service routine for each of the maskable interrupt requests (see Figure 5-4). The interrupt mask registers, INT_MASK and INT_MASK1, enable or disable (mask) individual interrupts (see Figures 5-5 and 5-6). With the exception of the nonmaskable interrupt (NMI) bit (INT_MASK1.7), setting a bit enables the corresponding interrupt source and clearing a bit disables the source.

To disable any interrupt, clear its mask bit. To enable an interrupt for standard interrupt service, set its mask bit and clear its PTS select bit. To enable an interrupt for PTS service, set both the mask bit and the PTS select bit.

Additionally, when you assign an interrupt to the PTS, you must set up a PTS control block (PTSCB) for each interrupt source (see “Initializing the PTS Control Blocks” on page 5-18) and use the EPTS instruction to globally enable the PTS. When you assign an interrupt to a standard software service routine, use the EI (enable interrupts) instruction to globally enable interrupt servicing.

NOTE

PTS routines will execute after a DI (disable interrupts) instruction, if the appropriate INT_MASK and PTSSEL bits are set. However, the end-of-PTS interrupt request will not occur. If an interrupt request occurs while interrupts are disabled, the corresponding pending bit is set in the INT_PEND or INT_PEND1 register.

5.5.1Programming the Multiplexed Interrupts

On the 87C196CA, the CAN-controller interrupts are multiplexed into the single CAN interrupt input (INT13). Write to the CAN control register (Figure 12-6 on page 12-13) to enable or disable global CAN interrupt sources (error, status change, and individual message object) and INT_MASK1.5 to enable or disable the multiplexed CAN interrupt.

The EPA4–9 and COMP0–1 e vent interrupts, the EPA0–9 overrun interrupts, and the timer 1 and timer 2 overflow/underflow interrupts are multiplexed into EPAx. Write to the EPA_MASK (Figure 10-12 on page 10-27) or EPA_MASK1 (Figure 10-13 on page 10-27) registers to enable or disable the multiplexed EPA interrupt sources and INT_MASK.0 to enable or disable the EPAx interrupt.

The PTS cannot determine the source of multiplexed interrupts, so do not use it to service these interrupts when more than one multiplexed interrupt is unmasked.

5-11

8XC196Kx, Jx, CA USER’S MANUAL

PTSSEL

Address:

04H

 

Reset State:

0000H

The PTS select (PTSSEL) register selects either a PTS microcode routine or a standard interrupt service routine for each interrupt requests. Setting a bit selects a PTS microcode routine; clearing a bit selects a standard interrupt service routine. When PTSCOUNT reaches zero, hardware clears the corresponding PTSSEL bit. The PTSSEL bit must be set manually to re-enable the PTS channel.

 

15

 

 

 

 

 

 

 

 

 

 

 

8

87C196CA

 

 

 

EXTINT

CAN

 

RI

 

 

TI

SSIO1

SSIO0

 

 

7

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

AD

 

EPA0

 

 

EPA1

EPA2

EPA3

EPAx

 

 

15

 

 

 

 

 

 

 

 

 

 

 

8

8XC196Jx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

EXTINT

 

RI

 

 

TI

SSIO1

SSIO0

 

 

7

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

AD

 

EPA0

 

 

EPA1

EPA2

EPA3

EPAx

 

15

 

 

 

 

 

 

 

 

 

 

 

8

8XC196Kx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

EXTINT

 

RI

 

 

TI

SSIO1

SSIO0

CBF

 

7

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

IBF

 

OBE

AD

 

EPA0

 

 

EPA1

EPA2

EPA3

EPAx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

 

 

 

 

 

 

 

Function

 

 

 

 

Number

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

14:0

Setting this bit causes the corresponding interrupt to be handled by a PTS microcode

(Note 1)

routine.

 

 

 

 

 

 

 

 

 

 

 

The PTS interrupt vector locations are as follows:

 

 

 

 

 

 

Bit Mnemonic Interrupt

 

 

 

 

PTS Vector

 

 

 

EXTINT

EXTINT pin

 

 

 

 

205CH

 

 

 

 

CAN (CA)

CAN Peripheral

 

 

 

 

205AH

 

 

 

 

RI

SIO Receive

 

 

 

 

2058H

 

 

 

 

TI

SIO Transmit

 

 

 

 

2056H

 

 

 

 

SSIO1

SSIO 1 Transfer

 

 

 

 

2054H

 

 

 

 

SSIO0

SSIO 0 Transfer

 

 

 

 

2052H

 

 

 

 

CBF (Kx)

Slave Port Command Buffer Full

2050H

 

 

 

 

IBF (Kx)

Slave Port Input Buffer Full

 

204EH

 

 

 

 

OBE (Kx)

Slave Port Output Buffer Empty

204CH

 

 

 

 

AD

A/D Conversion Complete

 

204AH

 

 

 

 

EPA0

EPA Capture/Compare Channel 0

2048H

 

 

 

 

EPA1

EPA Capture/Compare Channel 1

2046H

 

 

 

 

EPA2

EPA Capture/Compare Channel 2

2044H

 

 

 

 

EPA3

EPA Capture/Compare Channel 3

2042H

 

 

 

 

EPAx

Multiplexed EPA

 

 

 

 

2040H

 

 

 

PTS service is not recommended because the PTS cannot determine the source of

 

multiplexed interrupts.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.Bit 13 is reserved on the 8XC196Jx, Kx devices and bits 6–8 are reserved on the 87C196CA, 8XC196Jx devices. For compatibility with future devices, write zeros to these bits.

Figure 5-4. PTS Select (PTSSEL) Register

5-12

STANDARD AND PTS INTERRUPTS

INT_MASK

Address:

08H

 

Reset State:

00H

The interrupt mask (INT_MASK) register enables or disables (masks) individual interrupts. (The EI and DI instructions enable and disable servicing of all maskable interrupts.). INT_MASK is the low byte of the program status word (PSW). PUSHF or PUSHA saves the contents of this register onto the stack and then clears this register. Interrupt calls cannot occur immediately following this instruction. POPF or POPA restores it.

 

7

 

 

 

 

 

 

 

 

 

 

0

CA, Jx

 

 

AD

 

EPA0

 

 

EPA1

EPA2

EPA3

EPAx

 

 

7

 

 

 

 

 

 

 

 

 

 

0

8XC196Kx

 

 

 

 

 

 

 

 

 

 

 

 

 

IBF

OBE

AD

 

EPA0

 

 

EPA1

EPA2

EPA3

EPAx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

 

 

 

 

 

 

Function

 

 

 

 

Number

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7:0

Setting this bit enables the corresponding interrupt.

 

 

 

 

The standard interrupt vector locations are as follows:

 

 

 

 

 

Bit Mnemonic

Interrupt

 

 

 

 

Standard Vector

 

 

 

IBF (Kx)

 

Slave Port Input Buffer Full

 

200EH

 

 

 

 

OBE (Kx)

 

Slave Port Output Buffer Empty

200CH

 

 

 

 

AD

 

A/D Conversion Complete

 

200AH

 

 

 

 

EPA0

 

EPA Capture/Compare Channel 0

2008H

 

 

 

 

EPA1

 

EPA Capture/Compare Channel 1

2006H

 

 

 

 

EPA2

 

EPA Capture/Compare Channel 2

2004H

 

 

 

 

EPA3

 

EPA Capture/Compare Channel 3

2002H

 

 

 

 

EPAx††

 

Multiplexed EPA

 

 

 

 

2000H

 

 

 

†† EPA 4–9 capture/compare channel events, EPA 0–1 compare channel events, EPA 0–

 

9 capture/compare overruns, and timer overflows can generate this multiplexed interrupt.

 

The EPA mask and pending registers decode the EPAx interrupt. Write the EPA mask

 

registers (EPA_MASK and EPA_MASK1) to enable the interrupt sources; read the EPA

 

pending registers (EPA_PEND and EPA_PEND1) to determine which source caused the

 

interrupt.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bits 6–7 are reserved on the 87C196CA and 8XC196Jx devices. For compatibility with future devices, write zeros to these bits.

Figure 5-5. Interrupt Mask (INT_MASK) Register

5-13

8XC196Kx, Jx, CA USER’S MANUAL

INT_MASK1

Address:

13H

 

Reset State:

00H

The interrupt mask 1 (INT_MASK1) register enables or disables (masks) individual interrupts. (The EI and DI instructions enable and disable servicing of all maskable interrupts.) INT_MASK1 can be read from or written to as a byte register. PUSHA saves this register on the stack and POPA restores it.

 

7

 

 

 

 

 

 

 

 

 

 

0

87C196CA

 

NMI

 

EXTINT

CAN

 

RI

 

 

TI

SSIO1

SSIO0

 

 

7

 

 

 

 

 

 

 

 

 

 

0

8XC196Jx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

EXTINT

 

RI

 

 

TI

SSIO1

SSIO0

 

 

7

 

 

 

 

 

 

 

 

 

 

0

8XC196Kx

 

 

 

 

 

 

 

 

 

 

 

 

 

 

NMI

 

EXTINT

 

RI

 

 

TI

SSIO1

SSIO0

CBF

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

 

 

 

 

 

 

Function

 

 

 

 

Number

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7:0

Setting this bit enables the corresponding interrupt.

 

 

 

 

 

The standard interrupt vector locations are as follows:

 

 

 

 

 

Bit Mnemonic Interrupt

 

 

 

 

Standard Vector

 

 

 

NMI††

Nonmaskable Interrupt

 

203EH

 

 

 

 

EXTINT

EXTINT Pin

 

 

 

 

203CH

 

 

 

 

CAN (CA)

CAN Peripheral

 

 

 

 

203AH

 

 

 

 

RI

SIO Receive

 

 

 

 

2038H

 

 

 

 

TI

SIO Transmit

 

 

 

 

2036H

 

 

 

 

SSIO1

SSIO 1 Transfer

 

 

 

 

2034H

 

 

 

 

SSIO0

SSIO 0 Transfer

 

 

 

 

2032H

 

 

 

 

CBF (Kx)

Slave Port Command Buffer Full

2030H

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit 5 is reserved on the 8XC196Jx, Kx devices and bit 0 is reserved on the 87C196CA, 8XC196Jx devices. For compatibility with future devices, always write zeros to these bits.

†† NMI is always enabled. This nonfunctional mask bit exists for design symmetry with the INT_PEND1 register. Always write zero to this bit.

Figure 5-6. Interrupt Mask 1 (INT_MASK1) Register

5.5.2Modifying Interrupt Priorities

The software can modify the default priorities of maskable interrupts by controlling the interrupt mask registers (INT_MASK and INT_MASK1). For example, you can specify which interrupts, if any, can interrupt an interrupt service routine. The following code shows one way to prevent all interrupts, except EXTINT (priority 14), from interrupting an SIO receive interrupt service routine (priority12).

5-14

 

STANDARD AND PTS INTERRUPTS

SERIAL_RI_ISR:

 

PUSHA

; Save PSW, INT_MASK, INT_MASK1, & WSR

 

; (this disables all interrupts)

LDB INT_MASK1, #01000000B

; Enable EXTINT only

EI

; Enable interrupt servicing

 

; Service the RI interrupt

POPA

; Restore PSW, INT_MASK, INT_MASK1, &

 

; WSR registers

RET

 

CSEG AT 2038H

; fill in interrupt table

DCW SERIAL_RI_ISR

END

Note that location 2038H in the interrupt vector table must be loaded with the value of the label SERIAL_RI_ISR before the interrupt request occurs and that the receive interrupt must be enabled for this routine to execute.

This routine, like all interrupt service routines, is handled in the following manner:

1.After the hardware detects and prioritizes an interrupt request, it generates and executes an interrupt call. This pushes the program counter onto the stack and then loads it with the contents of the vector corresponding to the highest priority, pending, unmasked interrupt. The hardware will not allow another interrupt call until after the first instruction of the interrupt service routine is executed.

2.The PUSHA instruction, which is now guaranteed to execute, saves the contents of the PSW, INT_MASK, INT_MASK1, and window select register (WSR) onto the stack and then clears the PSW, INT_MASK, and INT_MASK1. In addition to the arithmetic flags, the PSW contains the global interrupt enable bit (I) and the PTS enable bit (PSE). By clearing the PSW and the interrupt mask registers, PUSHA effectively masks all maskable interrupts, disables standard interrupt servicing, and disables the PTS. Because PUSHA is a protected instruction, it also inhibits interrupt calls until after the next instruction executes.

3.The LDB INT_MASK1 instruction enables those interrupts that you choose to allow to interrupt the service routine. In this example, only EXTINT can interrupt the receive interrupt service routine. By enabling or disabling interrupts, the software establishes its own interrupt servicing priorities.

4.The EI instruction re-enables interrupt processing and inhibits interrupt calls until after the next instruction executes.

5.The actual interrupt service routine executes within the priority structure established by the software.

5-15

Соседние файлы в предмете Электротехника