Figure 92. Pwm Pulse Width Measurement Example - Holtek HT32F12345 User Manual

32-bit microcontroller with arm cortex-m3 core
Table of Contents

Advertisement

32-Bit Arm
®
Cortex
®
-M3 MCU
HT32F12345
Pulse Width Measurement
The input capture mode can be also used for pulse width measurement from signals on the MTn_
CHx pins, TIx. The following example shows how to configure the MCTM when operated in the
input capture mode to measure the high pulse width and the input period on the MTn_CH0 pin
using channel 0 and channel 1. The basic steps are shown as follows.
Configure the capture channel 0 (CH0CCS = 0x1) to select the TI0 signal as the capture input.
Configure the CH0P bit to 0 to choose the rising edge of the TI0 input as the active polarity.
Configure the capture channel 1 (CH1CCS = 0x2) to select the TI0 signal as the capture input.
Set the CH1P bit to 1 to choose the falling edge of the TI0 input as the active polarity.
Setup the TRSEL bits to 0x0001 to select TI0S0 as the trigger input.
Configure the Slave controller to operate in the Restart mode by setting the SMSEL field in the
MDCFR register to 0x4
Enable the input capture mode by setting the CH0E and CH1E bits in the CHCTR register to 1.
As the following diagram shows, the high pulse width on the MTn_CH0 pin will be captured into
the CH1CCR register while the input period will be captured into the CH0CCR register after an
input capture operation.
MTn_CH0
(TI0)
CNTR
7
CH0CCR
CH1CCR

Figure 92. PWM Pulse Width Measurement Example

Rev. 1.10
Restart mode
Reset counter value
Capture CH0
Capture CH1
0
1
2
3
4
5
302 of 590
Restart mode
Reset counter value
6
7
0
1
2
3
7
4
4
5
6
November 28, 2018

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the HT32F12345 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents