GD32W51x User Manual
362
2. Configure ISQ3 with the analog channel number;
3. Configure ADC_SAMPTx register;
4. Configure the ETMIC and ETSIC bits in the ADC_CTL1 register if it is needed;
5. Set the SWICST bit, or generate an external trigger for the inserted group;
6. Wait for the EOC/ EOIC flags to be set;
7. Read the converted result in the ADC_IDATA0 register;
8. Clear the EOC/ EOIC flags by writing 0.
Continuous conversion mode
This mode can be used in the regular channel group. The continuous conversion mode will
be enabled when the CTN bit in the ADC_CTL1 register is set. In this mode, the ADC performs
conversion on the channel specified in the RSQ0[4:0]. When the ADCON is 1, the ADC
samples and converts specified a channel, once the corresponding software trigger or
external trigger is active. The conversion data will be stored in the ADC_RDATA register.
Figure 14-3. Continuous conversion mode
CH2
CH2
CH2
CH2
CH2
CH2
EOC
Regular
trigger
Sample
Convert
CH2
Software procedure for continuous conversion on a regular channel:
1. Set the CTN bit in the ADC_CTL1 register;
2. Configure RSQ0 with the analog channel number;
3. Configure ADC_SAMPTx register;
4. Configure ETMRC and ETSRC bits in the ADC_CTL1 register if it is needed;
5. Set the SWRCST bit, or generate an external trigger for the regular group;
6. Wait for the EOC flag to be set;
7. Read the converted result in the ADC_RDATA register;
8. Clear the EOC flag by writing 0;
9. Repeat steps 6~8 as soon as the conversion is in need.
To avoid checking, DMA can be used to transfer the converted data:
1. Set the CTN and DMA bits in the ADC_CTL1 register;
2. Configure RSQ0 with the analog channel number;
3. Configure ADC_SAMPTx register;
4. Configure the ETMRC and ETSRC bits in the ADC_CTL1 register in if it is needed;
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 the SM bit in the ADC_CTL0 register is set.
In this mode, the ADC performs conversion on the channels with a specific sequence