mc9s08qg8 Freescale Semiconductor, Inc, mc9s08qg8 Datasheet - Page 188
![no-image](/images/manufacturer_photos/0/2/263/freescale_semiconductor__inc_sml.jpg)
mc9s08qg8
Manufacturer Part Number
mc9s08qg8
Description
Hcs08 Microcontrollers
Manufacturer
Freescale Semiconductor, Inc
Datasheet
1.MC9S08QG8.pdf
(300 pages)
Available stocks
Company
Part Number
Manufacturer
Quantity
Price
Company:
Part Number:
mc9s08qg84CDNE
Manufacturer:
Freescale Semiconductor
Quantity:
135
Company:
Part Number:
mc9s08qg84CDTE
Manufacturer:
Freescale Semiconductor
Quantity:
135
Part Number:
mc9s08qg8CDT
Manufacturer:
FREESCALE
Quantity:
20 000
Company:
Part Number:
mc9s08qg8CDTE
Manufacturer:
ABB
Quantity:
101
Company:
Part Number:
mc9s08qg8CDTE
Manufacturer:
Freescale Semiconductor
Quantity:
41 991
Part Number:
mc9s08qg8CDTE
Manufacturer:
FREESCALE
Quantity:
20 000
Part Number:
mc9s08qg8CFFE
Manufacturer:
FREESCALE
Quantity:
20 000
Company:
Part Number:
mc9s08qg8CPBE
Manufacturer:
CYPRESS
Quantity:
310
Modulo Timer (S08MTIMV1)
13.4
Functional Description
The MTIM is composed of a main 8-bit up-counter with an 8-bit modulo register, a clock source selector,
and a prescaler block with nine selectable values. The module also contains software selectable interrupt
logic.
The MTIM counter (
CNT) has three modes of operation: stopped, free-running, and modulo. Out of
MTIM
reset, the counter is stopped. If the counter is started without writing a new value to the modulo register,
then the counter will be in free-running mode. The counter is in modulo mode when a value other than
0x00 is in the modulo register while the counter is running.
After any MCU reset, the counter is stopped and reset to 0x00, and the modulus is set to 0x00. The bus
clock is selected as the default clock source and the prescale value is divide by 1. To start the MTIM in
free-running mode, simply write to the MTIM status and control register (
SC) and clear the MTIM
MTIM
stop bit (TSTP).
Four clock sources are software selectable: the internal bus clock, the fixed frequency clock (XCLK), and
an external clock on the TCLK pin, selectable as incrementing on either rising or falling edges. The MTIM
clock select bits (CLKS1:CLKS0) in
SC are used to select the desired clock source. If the counter is
MTIM
active (TSTP = 0) when a new clock source is selected, the counter will continue counting from the
previous value using the new clock source.
Nine prescale values are software selectable: clock source divided by 1, 2, 4, 8, 16, 32, 64, 128, or 256.
The prescaler select bits (PS[3:0]) in
SC select the desired prescale value. If the counter is active
MTIM
(TSTP = 0) when a new prescaler value is selected, the counter will continue counting from the previous
value using the new prescaler value.
The MTIM modulo register (
MOD) allows the overflow compare value to be set to any value from
MTIM
0x01 to 0xFF. Reset clears the modulo value to 0x00, which results in a free running counter.
When the counter is active (TSTP = 0), the counter increments at the selected rate until the count matches
the modulo value. When these values match, the counter overflows to 0x00 and continues counting. The
MTIM overflow flag (TOF) is set whenever the counter overflows. The flag sets on the transition from the
modulo value to 0x00. Writing to
MOD while the counter is active resets the counter to 0x00 and
MTIM
clears TOF.
Clearing TOF is a two-step process. The first step is to read the
SC register while TOF is set. The
MTIM
second step is to write a 0 to TOF. If another overflow occurs between the first and second steps, the
clearing process is reset and TOF will remain set after the second step is performed. This will prevent the
second occurrence from being missed. TOF is also cleared when a 1 is written to TRST or when any value
is written to the
MOD register.
MTIM
The MTIM allows for an optional interrupt to be generated whenever TOF is set. To enable the MTIM
overflow interrupt, set the MTIM overflow interrupt enable bit (TOIE) in
SC. TOIE should never be
MTIM
written to a 1 while TOF = 1. Instead, TOF should be cleared first, then the TOIE can be set to 1.
MC9S08QG8 and MC9S08QG4 Data Sheet, Rev. 1.01
188
Freescale Semiconductor