GD32VF103 User Manual
158
5.
Set the SWRCST bit, or generate an external trigger for the regular group
6.
Wait the EOC flag to be set
7.
Read the converted in the ADC_RDATA register
8.
Clear the EOC flag by writing 0 to it
9.
Repeat steps 6~8 as soon as the conversion is in need
To get rid of checking, DMA can be used to transfer the converted data:
1.
Set the CTN and DMA bit in the ADC_CTL1 register
2.
Configure RSQ0 with the analog channel number
3.
Configure ADC_SAMPTx register
4.
Configure ETERC and ETSRC bits in the ADC_CTL1 register if in need
5.
Prepare the DMA module to transfer data from the ADC_RDATA.
6.
Set the SWRCST bit, or generate an external trigger for the regular group
Scan conversion mode
The scan conversion mode will be enabled when SM bit in the ADC_CTL0 register is set. In
this mode, the ADC performs conversion on the channels with a specific sequence specified
in the ADC_RSQ0~ADC_RSQ2 registers or ADC_ISQ register. When the ADCON has been
set high, the ADC samples and converts specified channels one by one in the regular or
inserted group till the end of the regular or inserted group, once the corresponding software
trigger or external trigger is active. The conversion data will be stored in the ADC_RDATA or
ADC_IDATAx register. After conversion of the regular or inserted channel group, the EOC or
EOIC will be set. An interrupt will be generated if the EOCIE or EOICIE bit is set. The DMA
bit in ADC_CTL1 register must be set when the regular channel group works in scan mode.
After conversion of a regular channel group, the conversion can be restarted automatically if
the CTN bit in the ADC_CTL1 register is set.
Figure 11-4. Scan conversion mode, continuous disable
CH2
CH1
CH5
CH7
CH11
CH16
CH2
CH1
· · ·
Inserted
trigger
EOC
One circle of regular group, RL=7
CH9
CH10
CH8
CH6
CH9
CH10
· · ·
EOIC
One circle of inserted group, IL=3
Regular
trigger
Sample
Convert
CH12
CH17
Software procedure for scan conversion on a regular channel group:
1.
Set the SM bit in the ADC_CTL0 register and the DMA bit in the ADC_CTL1 register