Section 16 – general-purpose timers, 1 – detailed description, 1 – timer modes – Maxim Integrated DS4830A Optical Microcontroller User Manual

Page 143: Ds4830a user’s guide

Advertising
background image

DS4830A User’s Guide

143

SECTION 16 – GENERAL-PURPOSE TIMERS

The DS4830A has two identical 16-bit general-purpose timers. Each timer has the following,

• Two modes - Free synchronous and Compare
• Three Clock source selection options - Core clock, Peripheral clock and External clock
• 6 prescalers
• Interrupt feature in both modes.

Core Clock

00b or 01b

External Clock

11b

Clock Selection

MUX

Peripheral Clock

10b

Clock

Prescaler

GTPS[2:0]

GTV

15

0

0000h

15

GTC

0

RELOAD

Timer CLK

COMPARE

GTR

GTIF

GTIE

Next Timer Clock

Timer

Interrupt

Notes:

1. Free synchronous mode is a special compare mode in which the GTV is compared with 0xFFFF.

2. The GTV register is reset to 0x0000 when the GTR bit is set to ‘0’ (Timer off).

Compare Mode Block Diagram

Figure 16-1: Timer Functional Diagram

16.1 – Detailed Description

The DS4830A has two 16-bit programmable timer modules. Each timer module supports input clock selection
between Core, Peripheral and External clock sources. Each timer has two modes of operation i.e. free synchronous
timer and compare mode. The timer is controlled by the General Timer Reset (GTR) bit in the General Timer Control
Register (GTCN). When this bit is set to ‘1’, it enables the timer and starts counting up. When this bit is set to ‘0’, the
timer is stopped. Each timer has six prescalers selection feature. Using various prescaler and input clock options,
various timing loops can be generated.

16.1.1 – Timer Modes
Each timer has two modes of operation i.e. free synchronous timer and compare mode. The MODE bit in the GTCN
register selects the timer mode. The 16-bit free synchronous mode is configured by setting the MODE bit to 0. When
the Mode bit is set to ‘1’, compare mode is configured.

In free synchronous mode, the timer module begins counting up from 0x0000. When the General Timer Value
Register (GTV) value reaches to 0xFFFF, the GTIF interrupt flag is set to ‘1’ which generates an interrupt if enabled,
and the timer reloads the GTV register with 0x0000 at the next timer clock. The GTV register is a read only register
and it resets to 0x0000 when the timer is stopped. (GTR = 0).


In compare mode, the timer module begins counting from 0x0000 and when the value in the GTV register matches
the value in the General Timer Compare Register (GTC), the GTIF interrupt flag is set to ‘1 ‘ which generates an

Advertising