Software Timer
18-2
Élan™SC520 Microcontroller User’s Manual
18.3
REGISTERS
The software timer includes the registers listed in Table 18-1.
18.4
OPERATION
The software timer provides a very efficient hardware timebase for use by software. It is
designed to replace the traditional method of system timebase generation.
Traditionally, system timebase generation is accomplished by programming a timer to
generate a periodic interrupt. The interrupt service routine for this interrupt then increments
a counter each time the interrupt occurs. This value is often kept in a global variable, which
can then be accessed by other code that needs to track time. Sometimes, a procedural
interface (a function) is used to access the value of this counter. The counter maintained
by the interrupt service routine is usually set to zero at system initialization time. Thus, it
maintains the time since system boot.
The problem with this method is that it consumes a hardware timer resource. It also requires
an interrupt service routine that executes very frequently. Often the requirement to have a
higher resolution time is difficult to attain because the overhead of executing even a small
interrupt service routine many times a second is too much. It is rarely practical to provide
better than a 1-ms timebase with this technique. Also, in a system that makes extensive
use of interrupts, the timer interrupt can sometimes be missed, causing the interrupt counter
to becomes less accurate over time.
The software timer included on the ÉlanSC520 microcontroller can be used to resolve these
problems. The software timer provides a 16-bit millisecond counter (the Software Timer
Millisecond Count (SWTMRMILLI) register), a 10-bit microsecond-up counter (UPCTR),
and a latch register for the UPCTR (the Software Timer Microsecond Count
(SWTMRMICRO) register). Both counters reset to zero on system reset.
The microsecond-up counter increments at a rate of 1 MHz and rolls over on every 1000
counts (every 1 millisecond). When the microsecond-up counter rolls over, it signals the
millisecond counter to increment. When the millisecond counter is read, three things
happen:
1. The value in the Software Timer Millisecond Count (SWTMRMILLI) register (MMCR
offset C60h) is returned to software.
2. The value in the microsecond up counter is latched into the Software Timer Microsecond
Count (SWTMRMICRO) register (MMCR offset C62h).
3. The Software Timer Millisecond Count (SWTMRMILLI) register counter is reset to zero.
This operation allows software to keep track of time with no interrupt service routine.
Table 18-1
Software Timer Configuration Registers—Memory-Mapped
Register
Mnemonic
MMCR
Offset
Address
Function
Software Timer Millisecond
Count
SWTMRMILLI
C60h
Current 10-bit count value (milliseconds)
Software Timer Microsecond
Count
SWTMRMICRO
C62h
Current latched 16-bit count value
(microseconds)
Software Timer Configuration SWTMRCFG
C64h
Crystal frequency (33.000 MHz or 33.333 MHz)
Содержание Elan SC520
Страница 1: ...lan SC520 Microcontroller User s Manual Order 22004A...
Страница 4: ...iv lan SC520 Microcontroller User s Manual...
Страница 28: ...Introduction xxviii lan SC520 Microcontroller User s Manual...
Страница 42: ...Architectural Overview 1 14 lan SC520 Microcontroller User s Manual...
Страница 78: ...System Initialization 3 22 lan SC520 Microcontroller User s Manual...
Страница 108: ...Clock Generation and Control 5 10 lan SC520 Microcontroller User s Manual...
Страница 118: ...Reset Generation 6 10 lan SC520 Microcontroller User s Manual...
Страница 148: ...System Arbitration 8 24 lan SC520 Microcontroller User s Manual...
Страница 214: ...SDRAM Controller 10 36 lan SC520 Microcontroller User s Manual...
Страница 230: ...Write Buffer and Read Buffer 11 16 lan SC520 Microcontroller User s Manual...
Страница 288: ...GP Bus DMA Controller 14 22 lan SC520 Microcontroller User s Manual...
Страница 316: ...Programmable Interval Timer 16 8 lan SC520 Microcontroller User s Manual...
Страница 328: ...Software Timer 18 4 lan SC520 Microcontroller User s Manual...
Страница 346: ...Real Time Clock 20 12 lan SC520 Microcontroller User s Manual...
Страница 360: ...UART Serial Ports 21 14 lan SC520 Microcontroller User s Manual...
Страница 414: ...AMDebug Technology 26 8 lan SC520 Microcontroller User s Manual...