GD32W51x User Manual
370
variations than 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 reference voltage (V
REFINT
) provides a stable (bandgap) voltage output for the
ADC and comparators. V
REFINT
is internally connected to the ADC_IN10 input channel.
When the VBATEN bit of ADC_CCTL register is set, the external battery voltage can be
detected by ADC_IN11. To ensure the the V
BAT
voltage is no higher than V
DDA
, the battery
voltage is internal divided by 4.
To use the temperature sensor:
1.
Configure the conversion sequence (ADC_IN10) and the sampling time (t
s_temp
μs)
for the channel.
2.
Enable the temperature sensor by setting the TSVREN bit in ADC_CCTL.
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, please refer to device datasheet for more information.
Avg_Slope: Average Slope for curve between Temperature vs. V
temperature
, the typical
value please refer to device datasheet.
14.4.13.
On-chip hardware oversampling
The on-chip hardwareoversampling unit, which is enabled by OVSEN bit in the
ADC_OVSAMPCTL register, provides higher data resolution at the cost of lower output data
rate.
It provides a result with the following form, where N and M can be adjusted, and Dout(n) is
the n-th output digital signal of the ADC:
Result=
1
M
*
∑
D
OUT
(
n
)
n=N-1
n=0
(14-1)
The on-chip hardware oversampling circuit performs the following functions: summing and bit
right shifting. The oversampling ratio N is defined using the OVSR[2:0] bits in the
ADC_OVSAMPCTL register. It can range from 2x to 256x. The division coefficient M consists
of a right bit shift up to 8 bits. It is configured through the OVSS[3:0] bits in the
ADC_OVSAMPCTL register.
The summation unit can yield a result up to 20 bits (256 x 12-bit), which is first shifted right.
The upper bits of the result are then truncated, keeping only the 16 least significant bits
rounded to the nearest value using the least significant bits left apart by the shifting, before
being finally transferred into the data register.