mpc82g516a Megawin Technology, mpc82g516a Datasheet - Page 40

no-image

mpc82g516a

Manufacturer Part Number
mpc82g516a
Description
8-bit Microcontroller
Manufacturer
Megawin Technology
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
mpc82g516aE
Manufacturer:
MEGAWIN
Quantity:
1 200
Part Number:
mpc82g516aF
Manufacturer:
MEGAWIN
Quantity:
20 000
11 Timers/Counters
The MPC82G516A has three 16-bit Timer/Counters: Timer 0, Timer 1 and Timer 2. Each consists of two 8-bit
registers, THx and TLx (where, x= 0, 1, or 2). All of them can be configured to operate either as timers or event
counters.
In the Timer function, the TLx register is incremented every 12-clock cycle or 1-clock cycle, which is selectable by
software. Thus one can think of it as counting clock cycles. When counting every 12 clock cycles, the count rate
is 1/12 of the oscillator frequency.
In the Counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external
input pin- T0, T1, or T2. In this function, the external input is sampled every clock cycle for T0 pin and T1 pin, and
12-clock cycle for T2 pin. When the samples show a high and then a low, the count is incremented. The new
count value appears in the register when the transition was detected. For Timer 0 and Timer1, it takes 2 clock
cycles to recognize a 1-to-0 transition, the maximum count rate is 1/2 of the oscillator frequency; for Timer 2, it
takes 24 clock cycles to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency.
There are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled
at least once before it changes, it should be held for at least one clock cycle for Timer 0 and Timer 1, and 12-
clock cycles for Timer 2.
For Timer 0 and Timer 2, in addition to their standard 8051’s timer function, some special new functions are
added in. The following sub-sections will describe these timer/counters in detail.
11.1 Timer 0 and Timer 1
The Timer or Counter function is selected by control bits C/-T in the Special Function Register TMOD, as shown
below. These two Timer/Counters have four operating modes, which are selected by bit-pairs (M1, M0) in TMOD.
Mode 0, 1 and 2 are the same for these two Timer/Counters. Mode 3 is different. In addition to TMOD, another
Special Function Registers TCON and AUXR2 contains several control bits and status flags related to these two
Timers, as also shown below.
TMOD (Address=89H, Timer/Counter Mode Control Register, Reset Value=0000,0000B)
GATE: Gating control when set. Timer/Counter 0 or 1 is enabled only while /INT0 or /INT1 pin is high and TR0 or
TR1 control pin is set. When cleared, Timer 0 or 1 is enabled whenever TR0 or TR1 control bit is set.
C/-T: Timer or Counter Selector. Clear for Timer operation (input from internal system clock). Set for Counter
operation (input from T0 or T1 input pin).
M1 M0
MEGAWIN
0
0
1
1
1
GATE
7
0
1
0
1
1
Operating Mode
8-bit Timer/Counter. THx with TLx as 5-bit prescaler.
16-bit Timer/Counter. THx and TLx are cascaded; there is no prescaler.
8-bit auto-reload Timer/Counter. THx holds a value which is to be reloaded into TLx each time it
overflows.
(Timer 0) TL0 is an 8-bit Timer/Counter controlled by the standard Timer 0 control bits. TH0 is an 8-bit
timer only controlled by Timer 1 control bits.
(Timer 1) Timer/Counter stopped.
C/-T
6
Timer 1
M1
5
M0
4
MPC82G516A Data Sheet
GATE
3
C/-T
2
Timer 0
M1
1
M0
0
40

Related parts for mpc82g516a