Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
8xC196EA microcontroller user's manual.1998.pdf
Скачиваний:
56
Добавлен:
23.08.2013
Размер:
8.29 Mб
Скачать

CHAPTER 11

EVENT PROCESSOR ARRAY (EPA)

Control applications often require high-speed event control. For example, the controller may need to periodically generate pulse-width modulated outputs, an analog-to-digital conversion, or an interrupt. In another application, the controller may monitor an input signal to determine the status of an external device. The event processor array (EPA) was designed to reduce the processor overhead associated with these types of event control. This chapter describes the EPA and its timers and explains how to configure and program them.

11.1 EPA FUNCTIONAL OVERVIEW

The EPA performs input and output functions associated with four timer/counters, timer 1 through timer 4 (Figure 11-1). In the input mode, the EPA monitors an input pin for an event: a rising edge, a falling edge, or an edge in either direction. When the event occurs, the EPA records the value of the timer/counter so that the event is tagged with a time. This is called an input capture. Input captures are buffered to allow two captures before an overrun occurs.

In the output mode, the EPA monitors a timer/counter and compares its value with a value stored in a register. When the timer/counter value matches the stored value, the EPA can trigger an event: a timer reset, an A/D conversion, or an output event (set a pin, clear a pin, toggle a pin, or take no action). This is called an output compare.

Each input capture or output compare sets an interrupt pending bit. This bit can optionally cause an interrupt. The EPA has 17 capture/compare channels (EPA16:0) and 8 specialized compareonly channels (OS7:0). These compare-only channels can capture the value of any other timer at the time of a compare event. Capturing the timer value while simultaneously triggering the compare event output is called output/simulcapture. This feature simplifies conversion between angle and time domains or between any two time bases.

11-1

8XC196EA USER’S MANUAL

 

 

 

Timer/Counter Unit

 

 

 

 

 

 

 

 

Timer 3

Timer4:1 Overflow

 

 

Timer 4

 

 

 

 

 

 

 

 

Timer 1

 

 

 

Timer 2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Output

OS7:0 Event

 

OS7:0

 

 

 

 

Simulcapture

 

 

 

 

 

 

 

 

 

 

 

Channels 0-7

EPA2:0 Overrun

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Capture/Compare

EPA16 Event

 

 

 

 

 

 

 

 

EPA15:0 Event

 

EPA16:0

 

 

 

 

 

Channels 0-16

 

 

 

 

 

 

 

 

 

 

 

 

 

EPA16:3 Overrun

EPAx_OVR Interrupt

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A3401-01

Figure 11-1. EPA Block Diagram

11.2 EPA AND TIMER/COUNTER SIGNALS AND REGISTERS

Table 11-1 describes the EPA and timer/counter input and output signals. Each signal shares a pin with a general-purpose I/O signal, as shown in the first column. Table 11-2 briefly describes the registers for EPA capture/compare channels, EPA compare-only channels, and timer/counters.

Table 11-1. EPA and Timer/Counter Signals

Port Pin

EPA

EPA

Description

Signals

Signal Type

 

 

 

 

 

 

P7.0

EPA0

I/O

High-speed input/output for capture/compare

 

 

 

channel 0.

 

T1CLK

I

External clock source for timer 1.

P7.1

EPA1

I/O

High-speed input/output for capture/compare

 

 

 

channel 1.

 

T1RST

I

External reset source for timer 1.

P7.2

EPA2

I/O

High-speed input/output for capture/compare

 

 

 

channel 2.

 

T2CLK

I

External clock source for timer 2.

P7.3

EPA3

I/O

High-speed input/output for capture/compare

 

 

 

channel 3.

 

T2RST

I

External reset source for timer 2.

P7.4

EPA4

I/O

High-speed input/output for capture/compare

 

 

 

channel 4.

 

T3CLK

I

External clock source for timer 3.

11-2

 

 

 

EVENT PROCESSOR ARRAY (EPA)

 

Table 11-1. EPA and Timer/Counter Signals (Continued)

 

 

 

 

Port Pin

EPA

EPA

Description

Signals

Signal Type

 

 

 

 

 

 

P7.5

EPA5

I/O

High-speed input/output for capture/compare

 

 

 

channel 5.

 

T3RST

I

External reset source for timer 3.

P7.6

EPA6

I/O

High-speed input/output for capture/compare

 

 

 

channel 6.

 

T4CLK

I

External clock source for timer 4.

P7.7

EPA7

I/O

High-speed input/output for capture/compare

 

 

 

channel 7.

 

T4RST

I

External reset source for timer 4.

P8.7:0

EPA15:8

I/O

High-speed input/output for capture/compare

 

 

 

channels 8–15.

P10.4

EPA16

I/O

High-speed input/output for capture/compare

 

 

 

channel 16.

P9.7:0

OS7:0

O

Outputs of compare-only (output/simulcapture)

 

 

 

channels 0–7.

11-3

8XC196EA USER’S MANUAL

Table 11-2. EPA Control and Status Registers

Mnemonic

Address

Description

 

 

 

EPA0_CON

1F5CH

EPAx Capture/Compare Control

EPA1_CON

1F58H

These registers control the functions of the capture/compare

EPA2_CON

1F54H

channels. These registers must be addressed as words.

EPA3_CON

1F50H

 

EPA4_CON

1F4CH

 

EPA5_CON

1F48H

 

EPA6_CON

1F44H

 

EPA7_CON

1F40H

 

EPA8_CON

1F3CH

 

EPA9_CON

1F38H

 

EPA10_CON

1F34H

 

EPA11_CON

1F30H

 

EPA12_CON

1F2CH

 

EPA13_CON

1F28H

 

EPA14_CON

1F24H

 

EPA15_CON

1F20H

 

EPA16_CON

1F1CH

 

EPA0_TIME

1F5EH

EPAx Capture/Compare Time

EPA1_TIME

1F5AH

In capture mode, these registers contain the captured timer

EPA2_TIME

1F56H

value. In compare mode, these registers contain the time at

EPA3_TIME

1F52H

which an event is to occur. In capture mode, these registers

EPA4_TIME

1F4EH

are buffered to allow two captures before an overrun occurs.

EPA5_TIME

1F4AH

In compare mode, however, they are not buffered.

EPA6_TIME

1F46H

 

EPA7_TIME

1F42H

 

EPA8_TIME

1F3EH

 

EPA9_TIME

1F3AH

 

EPA10_TIME

1F36H

 

EPA11_TIME

1F32H

 

EPA12_TIME

1F2EH

 

EPA13_TIME

1F2AH

 

EPA14_TIME

1F26H

 

EPA15_TIME

1F22H

 

EPA16_TIME

1F1EH

 

INT_MASK

0008H

Interrupt Mask

 

 

Bit 2 in this register enables and disables the shared

 

 

EPAx_OVR interrupt.

INT_PEND

0009H

Interrupt Pending

 

 

Bit 2 in this register is set to indicate that the shared

 

 

EPAx_OVR interrupt is pending.

OS0_CON

1EFCH

OSx Compare-only Control

OS1_CON

1EF8H

These registers control the functions of the specialized

OS2_CON

1EF4H

compare-only (output/simulcapture) channels. They must be

OS3_CON

1EF0H

addressed as words.

OS4_CON

1EECG

 

OS5_CON

1EE8H

 

OS6_CON

1EE4H

 

OS7_CON

1EE0H

 

11-4

 

 

 

EVENT PROCESSOR ARRAY (EPA)

 

Table 11-2. EPA Control and Status Registers (Continued)

 

 

 

 

Mnemonic

 

Address

Description

 

 

 

 

OS0_TIME

 

1EFEH

OSx Compare-only Time

OS1_TIME

 

1EFAH

These registers contain the time at which an event is to occur.

OS2_TIME

 

1EF6H

 

They must be addressed as words.

OS3_TIME

 

1EF2H

 

 

OS4_TIME

 

1EEEH

 

OS5_TIME

 

1EEAH

 

OS6_TIME

 

1EE6H

 

OS7_TIME

 

1EE2H

 

P7_DIR

 

1FCAH

Port Direction Register

P8_DIR

 

1FCBH

Each bit controls the configuration of the corresponding pin.

P9_DIR

 

1FC2H

 

Clearing a bit configures a pin as a complementary output;

P10_DIR

 

1FC3H

 

setting a bit configures a pin as a high-impedance input or an

 

 

 

 

 

 

open-drain output.

 

 

 

 

P7_MODE

 

1FC8H

Port Mode Register

P8_MODE

 

1FC9H

Each bit controls the mode of the corresponding pin. Setting a

P9_MODE

 

1FC0H

 

bit configures a pin as a special-function signal; clearing a bit

P10_MODE

 

1FC1H

 

configures a pin as a general-purpose I/O signal.

 

 

 

 

 

 

 

P7_PIN

 

1FCEH

Port Pin Register

P8_PIN

 

1FCFH

Each bit reflects the current state of the corresponding pin,

P9_PIN

 

1FC6H

 

regardless of the pin’s mode and configuration.

P10_PIN

 

1FC7H

 

 

P7_REG

 

1FCCH

Port Data Output Register

P8_REG

 

1FCDH

For I/O Mode (Px_MODE.x = 0)

P9_REG

 

1FC4H

 

When a port pin is configured as a complementary output

P10_REG

 

1FC5H

 

(Px_DIR.x = 0), setting the corresponding port data bit

 

 

 

 

 

 

drives a one on the pin, and clearing the corresponding

 

 

 

port data bit drives a zero on the pin.

 

 

 

When a port pin is configured as a high-impedance input

 

 

 

or an open-drain output (Px_DIR.x = 1), clearing the corre-

 

 

 

sponding port data bit drives a zero on the pin, and setting

 

 

 

the corresponding port data bit floats the pin, making it

 

 

 

available as a high-impedance input.

 

 

 

For Special-function Mode (Px_MODE.x = 1)

 

 

 

When a port pin is configured as an output (either comple-

 

 

 

mentary or open-drain), the corresponding port data bit

 

 

 

value is immaterial because the corresponding on-chip

 

 

 

peripheral or system function controls the pin.

 

 

 

To configure a pin as a high-impedance input, set both the

 

 

 

Px_DIR and Px_REG bits.

 

 

 

 

PIH0_INT_MASK

 

1E98H

Peripheral Interrupt Handler (PIH) Interrupt Mask

PIH1_INT_MASK

 

1EA8H

The bits in these registers enable or disable each interrupt

 

 

 

that is routed through the PIH.

PIH0_INT_PEND

 

1E9AH

Peripheral Interrupt Handler (PIH) Interrupt Pending

PIH1_INT_PEND

 

1EAAH

The bits in these registers are set by hardware to indicate that

 

 

 

a PIH interrupt source is pending.

11-5

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