CP3BT26

26.3TIMER INTERRUPTS

The Multi-Function Timer unit has four interrupt sources, designated A, B, C, and D. Interrupt sources A, B, and C are mapped into a single system interrupt called Timer Interrupt 1, while interrupt source D is mapped into a system interrupt called Timer Interrupt 2. Each of the four interrupt sources has its own enable bit and pending bit. The enable bits are named TAIEN, TBIEN, TCIEN, and TDIEN. The pending bits are named TAPND, TBPND, TCPND, and TDPND.

Timer Interrupts 1 and 2 are system interrupts TA and TB (IRQ14 and IRQ13), respectively.

Table 77 shows the events that trigger interrupts A, B, C, and D in each of the four operating modes. Note that some interrupt sources are not used in some operating modes.

26.4TIMER I/O FUNCTIONS

The Multi-Function Timer unit uses two I/O pins, called TA and TB. The function of each pin depends on the timer op- erating mode and the TAEN and TBEN enable bits. Table 78 shows the functions of the pins in each operating mode, and for each combination of enable bit settings.

When the TA pin is configured to operate as a PWM output (TAEN = 1), the state of the pin is toggled on each underflow of the TCNT1 counter. In this case, the initial value on the pin is determined by the TAOUT bit. For example, to start with TA high, software must set the TAOUT bit before en- abling the timer clock. This option is available only when the timer is configured to operate in Mode 1, 3, or 4 (in other words, when TCRA is not used in Capture mode).

Table 77 Timer Interrupts Overview

 

 

 

Interrupt

Mode 1

 

Mode 2

 

Mode 3

 

Mode 4

 

 

 

 

 

 

 

 

 

 

Sys. Int.

Pending

PWM + Counter

 

Dual Input Capture +

 

Dual Counter

 

Single Capture +

 

 

 

Bit

 

 

 

 

 

 

 

Counter

 

 

Counter

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Timer

 

TAPND

TCNT1 reload from

 

Input capture on TA

 

TCNT1 reload from

 

TCNT1 reload from

Int. 1

 

 

TCRA

 

transition

 

TCRA

 

TCRA

(TA Int.)

 

 

 

 

 

 

 

 

 

 

TBPND

TCNT1 reload from

 

Input Capture on TB

 

N/A

 

Input Capture on TB

 

 

 

 

 

 

 

 

 

 

TCRB

 

transition

 

 

 

transition

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TCPND

N/A

 

TCNT1 underflow

 

N/A

 

N/A

 

 

 

 

 

 

 

 

 

 

 

Timer

 

TDPND

TCNT2 underflow

 

TCNT2 underflow

 

TCNT2 reload from

 

TCNT2 underflow

Int. 2

 

 

 

 

 

 

TCRB

 

 

(TB Int.)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Table 78 Timer I/O Functions

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TAEN

Mode 1

 

Mode 2

 

Mode 3

 

Mode 4

I/O

 

 

 

 

 

 

 

 

 

 

 

 

 

Dual Input Capture +

 

 

 

Single Capture +

 

 

TBEN

PWM + Counter

 

 

Dual Counter

 

 

 

 

 

 

 

 

 

 

 

 

counter

 

 

counter

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TA

 

TAEN = 0

No Output

Capture TCNT1 into

No Output Toggle

No Output Toggle

 

 

TBEN = X

 

TCRA

 

 

 

 

 

 

 

 

 

 

 

 

 

TAEN = 1

Toggle Output on

Capture TCNT1 into

Toggle Output on

Toggle Output on

 

 

TBEN = X

Underflow of TCNT1

TCRA and Preset

Underflow of TCNT1

Underflow of TCNT1

 

 

 

 

 

TCNT1

 

 

 

 

 

 

 

 

 

 

 

TB

 

TAEN = X

Ext. Event or Pulse

Capture TCNT1 into

Ext. Event or Pulse

Capture TCNT2 into

 

 

TBEN = 0

Accumulate Input

TCRB

Accumulate Input

TCRB

 

 

 

 

 

 

 

 

 

TAEN = X

Ext. Event or Pulse

Capture TCNT1 into

Ext. Event or Pulse

Capture TCNT2 into

 

 

TBEN = 1

Accumulate Input

TCRB and Preset

Accumulate Input

TCRB and Preset

 

 

 

 

 

TCNT1

 

 

TCNT2

 

 

 

 

 

 

 

 

 

 

 

www.national.com

202

Page 202
Image 202
National CP3BT26 manual Timer Interrupts, Timer I/O Functions, Taen, Tben