C) Timer Functions - Motorola 68HC12 User Manual

Table of Contents

Advertisement

Timer Functions:
This section covers the operation of the timer module when it is used for non-
interrupt based operations, such as output compare and input capture functions.
Interrupt based timer features are discussed in chapter 5.
The basics of timer module operation:
There are several basic features of timer module that apply to both the input
capture and output compare functions, as well as interrupt driven Timer functions.
In order to make use of any timer based operations, the timer module must first be
enabled. This is done by setting _H12TSCR to 0x80.
bit (TEN), which then enables all timer operations.
_H12TSCR:
bit 7
bit 6
TEN
TSWAI
The Timer uses a counter, also called a free running counter, that is incremented
by one every clock pulse.
by the user if needed.
in the register _H12TCNT.
the user.
Port T is used as I/O pins for the timer input capture and timer output compare.
Each pin can serve as either an input capture or output compare pin.
of the pin is selected by the state of the _H12TIOS register.
corresponds to a pin of Port T.
input capture, when the bit is set to a one, the pin is used as an output compare.
Any combination of input captures and output compares can be selected by the user.
_H12TIOS:
bit 7
bit 6
pin 7
pin 6
The data for the input captures and output compares are stored in _H12TC0 to
_H12TC7. These are 16 bit registers.
free running counter will be latched into the register when the input capture is
triggered.
For output compare operations the value in the register is used to
trigger an action.
The 68HC12 also allows the user to assign pull-up resistors to the timer module
inputs.
This is done by writing a one to TPE in _H12TMSK2.
pull-ups.
A zero will disable them.
_H12TMSK2:
bit 7
bit 6
TOIE
unused
bit 5
bit 4
TSBCK
TFFCA
The free running counter on the 68HC12 can be accessed
The free running counter is a 16-bit value that is stored
It can be read at anytime, but can not be written to by
When the bit is set to 0, the pin is used as an
bit 5
bit 4
pin 5
pin 4
bit 5
bit 4
TPE
TDRB
This will set the Timer Enable
bit 3
bit 2
unused
unused
bit 3
bit 2
pin 3
pin 2
For input capture operations the value of the
bit 3
bit 2
TCRE
PR2
12
bit 1
bit 0
unused
unused
The function
Each bit in _H12TIOS
bit 1
bit 0
pin 1
pin 0
This will enable the
bit 1
bit 0
PR1
PR0

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents