SMT Function
SMT Function
SMT Function
Period Latch
Set SMTxPRAIF
SMT_window SMT
Clock SMTxPR
Sync
Circuit
Control Set SMTxIF
Logic Comparator
SMT_signal SMT
Clock
Sync
Circuit
24-bit
Reset SMTxCPR
Buffer
SMTxCLK<2:0>
SMTxCLK
SMTxSIG
sync
SMTxSIG_sync
SMTxWIN
sync
SMTxWIN_sync
SMTxGO
sync
SMTxGO_sync
The SMTxTMR register counts for the timer and these inputs active-low signals with the falling edge as
SMTxPR register holds the count for comparison. The the trigger point). The SMTxPS bits in SMTxCON0
SMTxCPR and SMTxCPW are the SMT capture period select the clock prescaler.
and SMT capture pulse-width registers used to capture The SMTxGO bit in the SMTxCON1 register acts as a
the timer register value on any SMT signal event. run control bit for the Timer (i.e., setting it will start the
timer counter operation). The REPEAT bit in
Modes of operation SMTxCON1, if set, repeats the acquisition until
stopped by software using the SMTxGO bit and, if the
The SMTxCON0 register contains an Enable bit to
bit is reset, the SMT peripheral will perform the
enable or disable the SMT. Enabling will supply power
acquisition one time and stop. The MODE bits in
to the SMT peripheral. The STP bit in SMTxCON0, if
SMTxCON1 select the mode of operation for the SMT
set, will generate an overflow interrupt when
listed in Table 1.
SMTxTMR is equal to SMTxPR, and if reset, the
SMTxTMR will overflow for a whole 24-bit count in
SMTxTMR with the corresponding overflow interrupt.
The WPOL, SPOL and CPOL bits in SMTxCON0 select
the active state of SMT_window, SMT_signal and SMT
clock input, respectively (i.e., setting them will make
SMTxCLK
SMTxGO
SMTxPR 7
SMTxTMR 0 1 2 3 4 5 6 7 1 2 3 4 5
SMTxIF
2. Gated Timer timer value is captured whenever the input signal goes
low or OFF in captured pulse-width register
In this mode, the signal is provided on SMT_signal
(SMTxCPW) with corresponding interrupt generated.
input and only the high or ON time of the signal is
measured cumulatively while the timer is running. The
SMTxGO
SMTxSIG
SMTxTMR 0 1 2 3 4 5 6
SMTxCPW 4 6
SMTxPWAIF
This mode can be used to find the total time for which
equipment with a feedback control system is in
operation. For example, to measure the total power
consumption of a compressor motor of a refrigerator or
a power supply for a consumer electronic equipment
over a particular period.
SMTxCLK
SMTxGO
SMTxSIG
SMTxTMR 0 1 2 3 4 5 6 0
SMTxCPW 3
SMTxCPR 6
SMTxPWAIF
SMTxPRAIF
This mode can be used to find the characteristics of a 4. High and Low Measurement
carrier signal on the receiver side of a communication This mode is similar to Period and Duty Cycle
system and demodulate signal with the help of a measurement mode. The difference in this mode is that
comparator and other peripherals. This can also be the timer count value resets on every signal edge and
used for the signal measurement mode in a simple restarts from ‘0’.
oscilloscope.
SMTxCLK
SMTxGO
SMTxSIG
SMTxTMR 0 1 2 3 1 2 3 0
SMTxCPW 3
SMTxCPR 3
SMTxPWAIF
SMTxPRAIF
SMTxGO
SMTxWIN
SMTxTMR 0 1 2 3 4 5 6 7 0
SMTxCPR 7
SMTxPRAIF
6. Gated Windowed Measurement rising edge event on the SMT_window input, the SMT
captured period register is updated with the current
In Gated Window Measurement mode, the ON time of
value of the timer and the corresponding interrupt is
the SMT signal input (SMTxSIG) is measured between
generated. The timer also resets and restarts counting.
two consecutive rising edges of the SMT window input
(SMTxWIN) called the measurement window. On every
SMTxGO
SMTxWIN
SMTxSIG
SMTxTMR 0 1 2 3 4 5 6
SMTxCPR 6
SMTxPRAIF
SMTxTMR halts and SMTxTMR is captured
SMTxTMR increments
hold count when in SMTxCPR with
when signal high
signal low interrupt
7. Time of Flight rising edge event on the SMT_signal input but there is
a second rising edge event on the SMT_window input,
In Time-of-Flight mode, the SMT measures the time
the timer will stop and the value of timer is captured into
between a window input event and a signal input event,
the capture pulse-width register with corresponding
that is the time between first rising edges of the window
interrupt generated. Setting the WPOL and SPOL bits
input (SMTxWIN) and the signal input (SMTxSIG). The
in the SMTxCON0 register to ‘0’ will enable rising edge
input edges can be configured either to be rising or
control and setting them to ‘1’ will enable falling edge
falling. The timer starts counting when the first rising
control. The time of flight restarts after this.
edge on the SMT_window input is detected. The timer
stops on the first rising edge of the SMT_signal input
and the timer value is captured into the capture period
register with the corresponding interrupt generated.
This is called the time-of-flight value. In case there is no
SMTxGO
SMTxWIN
SMTxSIG
SMTxTMR 0 1 2 3 4 5 6 0 1 2 3 4 5 6 7 8 9 1
SMTxCPR 6
SMTxCPW 9
SMTxPRAIF
SMTxPWAIF
SMTxTMR starts SMTxTMR stops counting after SMTxTMR restarts counting SMTxTMR stop & reset after
counting after SMTxSIG rising edge & SMTxCPR after SMTxWIN rising edge SMTxWIN rising edge & SMTxCPW
SMTxWIN rising edge is updated with interrupt is updated with interrupt
This mode can be used in SONAR, RADAR, collision reset. When a rising edge is detected on the
detection for vehicles and Ultrasonic Anemometer SMT_window input, the current timer value is captured
(wind direction and speed measurement), etc. into the capture period register with the corresponding
interrupt generated. When a falling edge is detected on
8. 24-bit Capture
the SMT_window input, the current timer value is
In this mode, the signal is given on the SMT_window captured into the capture pulse-width register with the
input. The timer starts counting as soon as the timer corresponding interrupt generated.
GO bit (SMTxGO) is set and stops when GO bit is
SMTxGO
SMTxWIN
SMTxTMR 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
SMTxCPR 2 11 20
SMTxCPW 3 12 21
SMTxPRAIF
SMTxPWAIF
9. 24-bit Counter counting when the GO bit is reset. On every rising edge
event on the SMT_window input signal, the current
In this mode, the internal SMT clock is disabled and the
value of timer is captured into the capture period
signal from SMT_signal is taken as the clock. The timer
register with the corresponding interrupt generated.
starts counting after the GO bit is set and stops
SMTxSIG
SMTxGO
SMTxWIN
SMTxTMR 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
SMTxCPW 6 13
SMTxGO
SMTxWIN
SMTxTMR 0 1 2 3 4 5 6 7 8 9 10 11
SMTxCPW 4 11
SMTxPWAIF
SMTxSIG
SMTxGO
SMTxWIN
SMTxTMR 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7
SMTxCPW 4 6
SMTxCPR 9
SMTxPWAIF
SMTxPRAIF
CONCLUSION
This technical brief familiarizes the reader with the
Signal Measurement Timer (SMT) on PIC
microcontrollers. The technical brief also explains the
various modes of operation with a few of its possible
applications. For certain important modes like Period
and Duty Cycle Measurement, Gated Window
Measurement and Time of Flight, illustrations with
timing diagrams are also provided. For Time-of-Flight
mode, the configuration of SMT is provided with a code
snippet, showing the settings of the different registers.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
CERTIFIED BY DNV Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
== ISO/TS 16949 ==
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.