The MTIM counter (MTIM_CNT) has three modes of operation: stopped, free-running,
and modulo. Out of 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 (MTIM_SC), and clear the 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
MTIM_CLK are used to select the desired clock source. If the counter is active
(SC[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 (CLK[PS]) in MTIM_CLK select the desired
prescale value. If the counter is active (SC[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 (MTIM_MOD) allows the overflow compare value to be set
to any value from 0x01 to 0xFF. Reset clears the modulo value to 0x00, which results in
a free running counter.
When the counter is active (SC[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 (SC[TOF]) is set
whenever the counter overflows. The flag sets on the transition from the modulo value to
0x00. Writing to MTIM_MOD while the counter is active resets the counter to 0x00 and
clears SC[TOF].
Clearing SC[TOF] is a two-step process. The first step is to read the MTIM_SC register
while SC[TOF] is set. The second step is to write a 0 to SC[TOF]. If another overflow
occurs between the first and second step, the clearing process is reset and SC[TOF] will
remain set after the second step is performed. This will prevent the second occurrence
from being missed. SC[TOF] is also cleared when a 1 is written to SC[TRST] or when
any value is written to the MTIM_MOD register.
Chapter 13 8-bit modulo timer (MTIM)
MC9S08PT60 Reference Manual, Rev. 4, 08/2014
Freescale Semiconductor, Inc.
403
Содержание MC9S08PT60
Страница 2: ...MC9S08PT60 Reference Manual Rev 4 08 2014 2 Freescale Semiconductor Inc...
Страница 34: ...MC9S08PT60 Reference Manual Rev 4 08 2014 34 Freescale Semiconductor Inc...
Страница 40: ...System clock distribution MC9S08PT60 Reference Manual Rev 4 08 2014 40 Freescale Semiconductor Inc...
Страница 120: ...Flash and EEPROM registers descriptions MC9S08PT60 Reference Manual Rev 4 08 2014 120 Freescale Semiconductor Inc...
Страница 200: ...Port data registers MC9S08PT60 Reference Manual Rev 4 08 2014 200 Freescale Semiconductor Inc...
Страница 228: ...System clock gating control registers MC9S08PT60 Reference Manual Rev 4 08 2014 228 Freescale Semiconductor Inc...
Страница 262: ...Human machine interfaces HMI MC9S08PT60 Reference Manual Rev 4 08 2014 262 Freescale Semiconductor Inc...
Страница 298: ...Functional Description MC9S08PT60 Reference Manual Rev 4 08 2014 298 Freescale Semiconductor Inc...
Страница 396: ...FTM Interrupts MC9S08PT60 Reference Manual Rev 4 08 2014 396 Freescale Semiconductor Inc...
Страница 440: ...Functional description MC9S08PT60 Reference Manual Rev 4 08 2014 440 Freescale Semiconductor Inc...
Страница 468: ...Initialization Application Information MC9S08PT60 Reference Manual Rev 4 08 2014 468 Freescale Semiconductor Inc...
Страница 570: ...Application information MC9S08PT60 Reference Manual Rev 4 08 2014 570 Freescale Semiconductor Inc...
Страница 648: ...Memory map and register description MC9S08PT60 Reference Manual Rev 4 08 2014 648 Freescale Semiconductor Inc...
Страница 676: ...Resets MC9S08PT60 Reference Manual Rev 4 08 2014 676 Freescale Semiconductor Inc...