GD32VF103 User Manual
164
be used to measure the ambient temperature of the device. The sensor output voltage can
be converted into a digital value by ADC. The sampling time for the temperature sensor is
recommended to be set to at least 17.1
µ
s. When this sensor is not in use, it can be put in
power down mode by resetting the TSVREN bit.
The output voltage of the temperature sensor changes linearly with temperature. Because
there is an offset, which is up to 45
°
C and varies from chip to chip due to process variation,
the internal temperature sensor is more suited for applications that detect temperature
variations instead of absolute temperature. When it is used to detect accurate temperature,
an external temperature sensor part should be used to calibrate the offset error.
The internal voltage reference (V
REFINT
) provides a stable (bandgap) voltage output for the
ADC and Comparators. V
REFINT
is internally connected to the ADC0_CH17 input channel.
To use the temperature sensor:
1.
Configure the conversion sequence (ADC_IN16) and the sampling time(
17.1μs) for
the channel.
2.
Enable the temperature sensor by setting the TSVREN bit in the ADC control
register 1 (ADC_CTL1).
3.
Start the ADC conversion by setting the ADCON bit (or by external trigger).
4.
Read the resulting temperature data(V
temperature
) in the ADC data register, and get
the temperature using the following formula:
Temperature (°C) = {(V
25
– V
temperature
(digit)) / Avg_Slope} + 25.
V
25
: V
temperature
value at 25°C, the typical value please refer to the datasheet.
Avg_Slope: Average Slope for curve between Temperature vs. V
temperature
, the typical
value please refer to the datasheet.
11.4.12.
Programmable resolution (DRES) - fast conversion mode
It is possible to obtain faster conversion time (t
ADC
) by reducing the ADC resolution.
The resolution can be configured to be either 12, 10, 8, or 6 bits by programming the
DRES[1:0] bits in the ADC_OVSAMPCTL register. Lower resolution allows faster conversion
time for applications where high data precision is not required. The DRES[1:0] bits must only
be changed when the ADCON bit is reset. Lower resolution reduces the conversion time
needed for the successive approximation steps as shown in
Table 11-5. t
CONV
timings depending on resolution
DRES[1:0]
bits
t
CONV
(ADC clock
cycles)
t
CONV
(ns) at
f
ADC
=14MHz
t
SMPL
(min)
(ADC clock
cycles)
t
ADC
(ADC clock
cycles)
t
ADC
(us) at
f
ADC
=14MHz
12
12.5
893 ns
1.5
14
1000 ns
10
10.5
750 ns
1.5
12
857 ns
8
8.5
607 ns
1.5
10
714 ns