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

EVENT PROCESSOR ARRAY (EPA)

11.5.3 Programming the Capture/Compare Channels

The EPAx_CON register controls the function of its assigned capture/compare channel. To program a compare event, always write to EPAx_CON (Figure 11-14) first to configure the EPA capture/compare channel, and then load the event time into EPAx_TIME (Figure 11-15). To program a capture event, you need only write to EPAx_CON.

EPAx_CON

Address:

See Table 11-2 on page 11-4

Cx = 0–16

Reset:

0000H

The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels.

15

TB1

7

 

 

 

 

 

 

 

MX1

MX0

RE

AD

 

 

 

 

8

TB0

CE

M1

M0

 

 

 

0

 

 

 

 

RTS1

RTS0

ON/RT

EMC

 

 

 

 

Bit

Bit

 

 

Function

Number

Mnemonic

 

 

 

 

 

 

 

 

15:13

Reserved; always write as zeros.

 

 

 

12:11

TB1:0

Time Base Select

 

 

Specifies the reference timer.

 

 

TB1 TB0

 

 

 

0

0

timer 1

 

 

0

1

timer 2

 

 

1

0

timer 3

 

 

1

1

timer 4

 

 

 

10

CE

Compare Enable

 

 

Determines whether the EPA channel operates in capture or compare

 

 

mode.

 

 

 

0

= capture mode

 

 

1

= compare mode

 

 

 

 

 

Figure 11-14. EPA Control (EPAx_CON) Registers

11-19

8XC196EA USER’S MANUAL

EPAx_CON (Continued)

Address:

See Table 11-2 on page 11-4

Cx = 0–16

Reset:

0000H

The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels.

15

TB1

7

 

 

 

 

 

 

 

MX1

MX0

RE

AD

 

 

 

 

8

TB0

CE

M1

M0

 

 

 

0

 

 

 

 

RTS1

RTS0

ON/RT

EMC

 

 

 

 

Bit

Bit

 

 

 

Function

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

9:8

M1:0

EPA Mode Select

 

 

In capture mode, specifies the type of event that triggers an input capture.

 

 

In compare mode, specifies the action that the EPA executes when the

 

 

reference timer matches the event time.

 

 

M1

M0

Capture Mode Event

 

 

0

 

0

no capture

 

 

0

 

1

capture on falling edge

 

 

1

 

0

capture on rising edge

 

 

1

 

1

capture on either edge

 

 

M1

M0

Compare Mode Action

 

 

0

 

0

no output

 

 

0

 

1

clear output pin

 

 

1

 

0

set output pin

 

 

1

 

1

toggle output pin

 

 

 

7:6

MX1:0

Cross-coupled Mode Select

 

 

If module cross-coupling is enabled, these bits specify the action that the

 

 

EPA executes on the cross-coupled pin when the reference timer matches

 

 

the event-time value.

 

 

MX1

MX0

Capture Mode Event

 

 

X

 

0

select associated pin for input

 

 

X

 

1

select cross-coupled pin for input

 

 

MX1

MX0

Compare Mode Action

 

 

0

 

0

no output

 

 

0

 

1

clear cross-coupled pin

 

 

1

 

0

set cross-coupled pin

 

 

1

 

1

toggle cross-coupled pin

 

 

 

 

5

RE

Re-enable

 

 

 

Re-enable applies to the compare mode only. It allows a compare event to

 

 

continue to execute each time the event-time register (EPAx_TIME)

 

 

matches the reference timer rather than only upon the first time match.

 

 

0

= compare function is disabled after a single event

 

 

1

= compare function always enabled

 

 

 

 

 

 

Figure 11-14. EPA Control (EPAx_CON) Registers (Continued)

11-20

EVENT PROCESSOR ARRAY (EPA)

EPAx_CON (Continued)

Address:

See Table 11-2 on page 11-4

Cx = 0–16

Reset:

0000H

The EPA control (EPAx_CON) registers control the functions of their assigned capture/compare channels.

15

TB1

7

 

 

 

 

 

 

 

MX1

MX0

RE

AD

 

 

 

 

8

TB0

CE

M1

M0

 

 

 

0

 

 

 

 

RTS1

RTS0

ON/RT

EMC

 

 

 

 

Bit

Bit

 

 

Function

Number

Mnemonic

 

 

 

 

 

 

 

 

 

4

AD

A/D Conversion

 

 

 

Allows the EPA to start an A/D conversion that has been previously set up in

 

 

the A/D command registers. To use this feature, you must select the EPA as

 

 

the conversion source in the AD_COMMAND register.

 

 

0 = causes no A/D action

 

 

1 = EPA capture or compare event triggers an A/D conversion

 

 

 

3:2

RTS1:0

Reset Timer Select

 

 

Selects the timer that is to be reset if the RT bit (EPAx_CON.1) is set.

 

 

RTS1 RTS0

 

 

 

0

0

select timer 1 for reset

 

 

0

1

select timer 2 for reset

 

 

1

0

select timer 3 for reset

 

 

1

1

select timer 4 for reset

 

 

 

1

ON/RT

Overwrite New/Reset Timer

 

 

The ON/RT bit functions as overwrite new in capture mode and reset timer

 

 

in compare mode.

 

 

In Capture Mode (ON):

 

 

An overrun error is generated when an input capture occurs while the event-

 

 

time register (EPAx_TIME) and its buffer are both full. When an overrun

 

 

occurs, the ON bit determines whether old data is overwritten or new data is

 

 

ignored:

 

 

 

0

= ignores new data

 

 

1

= overwrites old data in the buffer

 

 

In Compare Mode (RT):

 

 

0

= disables the reset function

 

 

1

= resets the RTS-selected timer

 

 

 

0

EMC

Enable Module Concatenation

 

 

Used in conjunction with TxCONTROL.8, this bit allows an EPA channel to

 

 

enable an adjacent channel, providing a 32-bit time base.

 

 

0 =disable

 

 

 

1 =enable concatenation

 

 

 

 

 

Figure 11-14. EPA Control (EPAx_CON) Registers (Continued)

11-21

8XC196EA USER’S MANUAL

EPAx_TIME

Address:

Table 11-2

x = 0–16

Reset State:

XXXXH

The EPA time (EPAx_TIME) registers are the event-time registers for the EPA channels. In capture mode, the value of the reference timer is captured in EPAx_TIME when an input transition occurs. Each event-time register is buffered, allowing the storage of two capture events at once. In compare mode, the EPA triggers a compare event when the reference timer matches the value in EPAx_TIME. EPAx_TIME is not buffered for compare mode.

15

0

EPA Time Value

Bit

Function

Number

15:0 EPA Time Value

When an EPA channel is configured for capture mode, this register contains the value of the reference timer when the specified event occurred.

When an EPA channel is configured for compare mode, write the compare event time to this register.

Figure 11-15. EPA Time (EPAx_TIME) Registers

11.5.4 Programming the Compare-only (Output/Simulcapture) Channels

To program a compare event, you must first write to the OSx_CON register (Figure 11-16) to configure the compare-only channel and then load the event time into OSx_TIME (Figure 11-17).

11-22

EVENT PROCESSOR ARRAY (EPA)

OSx_CON

Address: See Table 11-2 on page 11-4

x = 0–7

Reset:

0000H

The output/simulcapture control (OSx_CON) registers control the functions of their assigned output/simulcapture channels.

15

TB1

7

 

 

 

 

 

 

 

MX1

MX0

RE

AD

 

 

 

 

8

TB0

CE

M1

M0

 

 

 

0

 

 

 

 

CS1

CS0

SE

EMC

 

 

 

 

Bit

Bit

 

 

 

Function

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

15:13

Reserved; always write as zeros.

 

 

 

12:11

TB1:0

Time Base Select

 

 

Specifies the reference timer.

 

 

TB1

TB0

 

 

 

0

 

0

timer 1

 

 

0

 

1

timer 2

 

 

1

 

0

timer 3

 

 

1

 

1

timer 4

 

 

 

10

CE

Compare Enable

 

 

Enables the compare function of the output/simulcapture channel.

 

 

0

= compare function disabled

 

 

1

= compare function enabled

 

 

 

 

9:8

M1:0

Mode Select

 

 

 

Specifies the action that the EPA executes when the reference timer

 

 

matches the event-time value.

 

 

M1

M0

 

 

 

0

 

0

no output

 

 

0

 

1

clear output pin

 

 

1

 

0

set output pin

 

 

1

 

1

toggle output pin

 

 

 

7:6

MX1:0

Cross-coupled Mode Select

 

 

If module cross-coupling is enabled, this bit specifies the action that the

 

 

EPA executes on the cross-coupled pin when the reference timer matches

 

 

the event-time value.

 

 

MX1

MX0

 

 

 

0

 

0

no output

 

 

0

 

1

clear cross-coupled pin

 

 

1

 

0

set cross-coupled pin

 

 

1

 

1

toggle cross-coupled pin

 

 

 

 

 

 

Figure 11-16. Output/Simulcapture x Control (OSx_CON) Register

11-23

8XC196EA USER’S MANUAL

OSx_CON (Continued)

Address: See Table 11-2 on page 11-4

x = 0–7

Reset:

0000H

The output/simulcapture control (OSx_CON) registers control the functions of their assigned output/simulcapture channels.

15

TB1

7

 

 

 

 

 

 

 

MX1

MX0

RE

AD

 

 

 

 

8

TB0

CE

M1

M0

 

 

 

0

 

 

 

 

CS1

CS0

SE

EMC

 

 

 

 

Bit

Bit

 

 

Function

Number

Mnemonic

 

 

 

 

 

 

 

 

 

5

RE

Re-enable

 

 

 

Allows a compare event to continue to execute each time the reference

 

 

timer matches the event-time register value, rather than only upon the first

 

 

match.

 

 

 

0

= compare function will drive the output only once

 

 

1

= compare function always enabled

 

 

 

4

AD

A/D Conversion

 

 

Allows the EPA to start an A/D conversion that has been previously set up

 

 

in the A/D command registers. To use this feature, you must select the EPA

 

 

as the conversion source in the AD_COMMAND register.

 

 

0

= causes no A/D action

 

 

1

= OS compare event triggers an A/D conversion

 

 

 

3:2

CS1:0

Simulcapture Timer Select

 

 

Selects the timer whose value is to be captured when the output event is

 

 

generated.

 

 

 

CS1 CS0

Reference Timer

 

 

0

0

timer 1

 

 

0

1

timer 2

 

 

1

0

timer 3

 

 

1

1

timer 4

 

 

 

1

SE

Simulcapture Enable

 

 

Enables the simulcapture function of the output/simulcapture channel.

 

 

0

= simulcapture function disabled

 

 

1

= simulcapture function enabled (if compare occurs)

 

 

 

0

EMC

Enable Module Concatenation

 

 

Used in conjunction with TxCONTROL.8, this bit allows an output/simul-

 

 

capture channel to enable an adjacent channel, providing a 32-bit time

 

 

base.

 

 

 

0

=disable

 

 

 

1

=enable concatenation

 

 

 

 

 

Figure 11-16. Output/Simulcapture x Control (OSx_CON) Register (Continued)

11-24

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