
GD32F403xx User Manual
200
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 the triggers.
4.
Rea
d the internal temperature sensor output voltage(V
temperature
), and get the
temperature with the following equation:
Temperature (°C) = {(V
25
– V
temperature
) / Avg_Slope} + 25.
V
25
: internal temperature sensor output voltage at 25°C, the typical value please
refer to the datasheet.
Avg_Slope: average slope for curve between temperature vs. internal temperature
sensor output voltage, the typical value please refer to the datasheet.
12.4.12.
Programmable resolution (DRES)
The resolution is configured by programming the DRES[1:0] bits in the ADC_OVSAMPCTL
register. For applications that do not require high data accuracy, lower resolution allows faster
conversion time. The DRES[1:0] bits must only be changed when the ADCON bit is reset.
Lower resolution reduces the conversion time needed f or the successive approximation steps
as shown in
Table 12-5. tCONV timings depending on resolution.
Table 12-5. t
CONV
timings depending on resolution
DRES[1:0]
bits
t
CONV
(ADC clock
cycles)
t
CONV
(ns) at
f
ADC
=30MHz
t
SMPL
(min)
(ADC clock
cycles)
t
ADC
(ADC clock
cycles)
t
ADC
(us) at
f
ADC
=30MHz
12
12.5
417 ns
1.5
14
467 ns
10
10.5
350 ns
1.5
12
400 ns
8
8.5
283 ns
1.5
10
333 ns
6
6.5
217 ns
1.5
8
267 ns
12.4.13.
On-chip hardware oversampling
The on-chip hardware oversampling circuit performs data preprocessing to offload the CPU.
It can handle multiple conversions and average them into a single data with increased data
width, up to 16-bit.
The on-chip hardware oversampling circuit is enabled by OVSEN bit in the
ADC_OVSAMPCTL register. It provides a result with the following form, where N and M can
be adjusted, and D
out
(n) is the n-th output digital signal of the ADC:
Result =
1
M
∗ ∑
D
𝑜𝑢𝑡
(n)
N−1
n=0
(12-1)
The on-chip hardware oversampling circuit performs the following functions: summing and bit
right shifting. The oversampling ratio N is defined by the OVSR[2:0] bits in the
ADC_OVSAMPCTL register. It can range from 2x to 256x. The division coefficient M means
bit right shifting up to 8-bit. It is configured through the OVSS[3:0] bits in the
ADC_OVSAMPCTL register.