Figure 44. Pwm Pulse Width Measurement Example - Holtek HT32F50231 User Manual

32-bit microcontroller with arm cortex-m0+
Table of Contents

Advertisement

32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F50231/HT32F50241
Pulse Width Measurement
The input capture mode can be also used for pulse width measurement from signals on the GT_
CHx pins, TIx. The following example shows how to configure the GPTM operated in the input
capture mode to measure the high pulse width and the input period on the GT_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.
Configure the CH1P bit to 1 to choose the falling edge of the TI0 input as the active polarity.
Configure the TRSEL bits to 0x1 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 GT_CH0 pin will be captured into
the CH1CCR register while the input period will be captured into the CH0CCR register after input
capture operation.
Restart mode
Reset counter value
GT_CH0
(TI0)
CNTR
0
7
CH0CCR
CH1CCR

Figure 44. PWM Pulse Width Measurement Example

Rev. 1.00
Capture CH0
Capture CH1
1
2
3
4
5
196 of 486
Restart mode
Reset counter value
6
7
0
1
2
3
7
4
4
5
6
July 31, 2018

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Ht32f50241

Table of Contents