Rev. 1.00
52
March 24, 2020
Rev. 1.00
53
March 24, 2020
BS83A04C
4-Key Enhanced Touch I/O Flash MCU
BS83A04C
4-Key Enhanced Touch I/O Flash MCU
Timer Module – TM
One of the most fundamental functions in any microcontroller device is the ability to control and
measure time. To implement time related functions the device includes a Timer Module, abbreviated
to the name TM. The TM is multi-purpose timing units and serve to provide operations such as
Timer/Counter, Compare Match Output as well as being the functional unit for the generation of
PWM signals. The TM has two individual interrupts. The addition of input and output pins for each
TM ensures that users are provided with timing units with a wide and flexible range of features.
The general features of the Compact type TM are described here with more detailed information
provided in the individual Compact type TM section.
Introduction
The device contains a Compact type TM. The main features of the CTM are summarised in the
accompanying table.
Function
CTM
Timer/Counter
√
Compare Match Output
√
PWM Output
√
PWM Alignment
Edge
PWM Adjustment Period & Duty
Duty or Period
CTM Function Summary
TM Operation
The Compact type TM offers a diverse range of functions, from simple timing operations to
PWM signal generation. The key to understanding how the TM operates is to see it in terms of
a free running counter whose value is then compared with the value of pre-programmed internal
comparators. When the free running counter has the same value as the pre-programmed comparator,
known as a compare match situation, a TM interrupt signal will be generated which can clear the
counter and perhaps also change the condition of the TM output pin. The internal TM counter is
driven by a user selectable clock source, which can be an internal clock or an external pin.
TM Clock Source
The clock source which drives the main counter in each TM can originate from various sources. The
selection of the required clock source is implemented using the CTCK2~CTCK0 bits in the CTM
control registers. The clock source can be a ratio of the system clock f
SYS
or the internal high clock
f
H
, the f
SUB
clock source or the external CTCK pin. The CTCK pin clock source is used to allow an
external signal to drive the TM as an external clock source or for event counting.
TM Interrupts
The Compact type TM has two internal interrupts, the internal comparator A or comparator P, which
generate a TM interrupt when a compare match condition occurs. When a TM interrupt is generated,
it can be used to clear the counter and also to change the state of the TM output pin.
TM External Pins
The Compact type TM has one TM input pin, with the label CTCK. The CTM input pin, CTCK, is
essentially a clock source for the CTM and is selected using the CTCK2~CTCK0 bits in the CTMC0
register. This external TM input pin allows an external clock source to drive the internal TM. The
CTCK input pin can be chosen to have either a rising or falling active edge.