ADC¶
Function introduction¶
The chip integrates a 12 bit ADC, and its main features are as follows:
- ADC resolution is 12 bit;
- The sampling rate can reach 1 MSPS (15 cycles are required for one conversion, so to achieve the sampling rate of 1 MSPS, the clock frequency must be 15 MHz);
- 6-channel single ended input. Note that only channel 2-channel 5 is introduced from the chip. Channel 0 and channel 1 are used internally by the chip, and users do not need to configure them;
- Operating current 450 at 1MSPS μ A; Current less than 1 when closed μ A;
- Single sampling and continuous sampling modes are available, and the sampling mode timing is shown in the figure below.
Register Mapping¶
The base address of ADC register mapping is 0x40002000, and the specific register mapping is shown in Table A-1.
Offset | Name | Bit Width | Type | Reset Value | Description |
---|---|---|---|---|---|
0x00 | ADCCTRL | 32 | R/W | 0x00000000 | ADC control register |
0x04 | ADCINTMASK | 16 | R/W | 0x0000 | ADC interrupt mask register |
0x08 | ADCINTFLG | 16 | RO | 0x0000 | ADC interrupt flag register |
0x0C | ADCINTCLR | 16 | WO | 0x0000 | ADC interrupt clear register |
0x10 | ADCSOFTSOC | 16 | R/W | 0x0000 | ADC software trigger register |
0x14 | ADCSOCCTRL | 32 | R/W | 0x00000000 | ADC conversion control register |
0x18-0x24 | ADCRESULT2-ADCRESULT5 | 16 | R/W | 0x0000 | ADC conversion result register |
0x38 | CH0PERIOD | 16 | RO | 0x0000 | Channel 0 sampling period |
0x3C | CH1PERIOD | 16 | R/W | 0x0000 | Channel 1 sampling period |
0x40 | CH2PERIOD | 16 | R/W | 0x0000 | Channel 2 sampling period |
0x44 | CH3PERIOD | 16 | R/W | 0x0000 | Channel 3 sampling period |
0x48 | CH0MINVALUE | 16 | R/W | 0x0000 | Channel 0 lower threshold |
0x4C | CH0MAXVALUE | 16 | R/W | 0x0FFF | Channel 0 upper limit threshold |
0x50 | CH1MINVALUE | 16 | R/W | 0x0001 | Lower threshold of channel 1 |
0x54 | CH1MAXVALUE | 16 | R/W | 0x0FFF | Upper threshold of channel 1 |
0x58 | CH2MINVALUE | 16 | R/W | 0x0001 | Lower threshold of channel 2 |
0x5C | CH2MAXVALUE | 16 | R/W | 0x0FFF | Upper threshold of channel 2 |
0x60 | CH3MINVALUE | 16 | R/W | 0x0001 | Lower threshold of channel 3 |
0x64 | CH3MAXVALUE | 16 | R/W | 0x0FFF | Upper threshold of channel 3 |
0x68 | ADCSTAT | 16 | R | 0x0000 | ADC status register |
0x6C | ADCCTRLa | 32 | R/W | 0x00000000 | ADC control register a |
0x70 | ADCRSTN | 32 | R/W | 0x00000000 | ADC reset configuration register |
0x74 | ADCOFFSET | 32 | R/W | 0x00000000 | ADC offset calibration register |
0x78 | ADCLOADEN | 32 | R/W | 0x00000000 | ADC load register |
0x7C | ADCPWRRDY | 32 | R/W | 0x00000000 | ADC reset status register |
0x80 | CH4PERIOD | 16 | R/W | 0x0000 | Channel 4 sampling period |
0x84 | CH5PERIOD | 16 | R/W | 0x0000 | Channel 5 sampling period |
0x88 | CH4MINVALUE | 16 | R/W | 0x0000 | Lower threshold of channel 4 |
0x8C | CH4MAXVALUE | 16 | R/W | 0x0FFF | Upper threshold of channel 4 |
0x90 | CH5MINVALUE | 16 | R/W | 0x0000 | Lower threshold of channel 5 |
0x94 | CH5MAXVALUE | 16 | R/W | 0x0FFF | Upper threshold of channel 5 |
ADC control register (ADCCTRL)¶
Offset: 0x00
Reset value: 0x00000000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
31:24 | Reserved | 0x00 | R/W | Reserved |
23 | CH3MAXEN | 0 | R/W | CH3 Sampling Result Upper Threshold Interrupt Enable 0: Off 1: On |
22 | CH2MAXEN | 0 | R/W | CH2 sampling result threshold upper limit interrupt enable 0: off 1: on |
21 | CH1MAXEN | 0 | R/W | CH1 Sampling result threshold upper limit interrupt enable 0: Off 1: On |
20 | CH0MAXEN | 0 | R/W | CH0 upper limit of sampling result threshold interrupt enable 0: off 1: on |
19 | CH3MINEN | 0 | R/W | CH3 Sampling Result Threshold Lower Limit Interrupt Enable 0: Off 1: On |
18 | CH2MINEN | 0 | R/W | CH2 Sampling Result Threshold Lower Limit Interrupt Enable 0: Off 1: On |
17 | CH1MINEN | 0 | R/W | CH1 Sampling Result Threshold Lower Limit Interrupt Enable 0: Off 1: On |
16 | CH0MINEN | 0 | R/W | CH0 Sampling result threshold lower limit Interrupt enable 0: Off 1: On |
15: 13 | Reserved | 0x0 | R/W | Reserved |
12 | INTSEL | 0 | R/W | Interrupt generation condition selection 0: Interrupt request is generated at the end of each sampling 1: Interrupt request is generated when the sampling value is abnormal (exceeds the threshold value) This bit can only be configured as 1 when ADCCTRL [8] is configured as 1 in the monitoring mode |
11: 9 | Reserved | 0x0 | R/W | Reserved |
8 | PERIODEN | 0 | R/W | Periodic monitoring enable (can only work in single sampling mode) 0: Off 1: On |
7 | CH3EN | 0 | R/W | Channel 3 cycle monitoring enable 0: Off 1: On |
6 | CH2EN | 0 | R/W | Channel 2 cycle monitoring enable 0: OFF 1: ON |
5 | CH1EN | 0 | R/W | Channel 1 cycle monitoring enable 0: OFF 1: ON |
4 | CH0EN | 0 | R/W | Channel 0 cycle monitoring enable 0: Off 1: On |
2 | Reserved | 0 | R/W | Reserved |
1 | CONTEN | 0 | R/W | Continuous conversion enable 0: Single conversion mode 1: If SOCSOFT bit remains high, ADC will convert continuously |
0 | ADCEN | 0 | R/W | ADC circuit enable |
ADC interrupt mask register (ADC INTMSK)¶
Offset: 0x04
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 1 | Reserved | 0x0000 | R/W | Reserved |
0 | EOC_ INT_ EN | 0 | R/W | ADC interrupt mask bit 0: not masked 1: masked |
ADC Interrupt Flag Register (ADCINTFLG)¶
Offset: 0x08
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 4 | Reserved | 0x000 | RO | Reserved |
3 | ADCFLG3 | 0 | RO | ADC channel 3 conversion completion interrupt flag bit, highly effective |
2 | ADCFLG2 | 0 | RO | ADC channel 2 conversion completion interrupt flag bit, highly effective |
1 | ADCFLG1 | 0 | RO | ADC channel 1 conversion completion interrupt flag bit, highly effective |
0 | ADCFLG0 | 0 | RO | ADC channel 0 conversion completion interrupt flag bit, highly effective |
ADC Interrupt Clear Register (ADCINTCLR)¶
Offset: 0x0C
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 9 | Reserved | 0x00 | WO | Reserved |
8 | ADCINT_ CLR | 0 | WO | Clear all channel interrupt flags, highly effective |
7: 4 | Reserved | 0x0 | WO | Reserved |
3 | ADCCLR3 | 0 | WO | ADC channel 3 conversion completion interrupt flag cleared, highly effective |
2 | ADCCLR2 | 0 | WO | ADC channel 2 conversion completion interrupt flag cleared, highly effective |
1 | ADCCLR1 | 0 | WO | ADC channel 1 conversion completion interrupt flag cleared, highly effective |
0 | ADCCLR0 | 0 | WO | ADC channel 0 conversion completion interrupt flag cleared, highly effective |
ADC Software Trigger Register (SOCSOFTCTRL)¶
Offset: 0x10
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 1 | Reserved | 0x0000 | R/W | Reserved |
0 | SOCSOFT | 0 | R/W | ADC start conversion 0: no action 1: ADC start conversion |
ADC conversion control register (ADCSOCCTRL)¶
Offset: 0x14
Reset value: 0x00000000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
31:15 | Reserved | 0x00000 | R/W | Reserved |
14: 12 | SHTIME | 0x0 | R/W | Selection of sampling holding time: 0: SOC length is 1 AD_ CLK cycle 1: SOC length is 2 ADs_ CLK cycle 2: SOC length is 3 ADs_ CLK cycle 3: SOC length is 4 ADs_ CLK cycle 4: SOC length is 5 ADs_ CLK cycle other:invalid value |
11: 8 | Reserved | 0x0 | R/W | Reserved |
7: 5 | CHSEL | 0x0 | R/W | Conversion channel selection 0: ADC_ IN0 1:ADC_ IN1 2:ADC_ IN2 3:ADC_ IN3 |
4: 0 | Reserved | 0x00 | R/W | Reserved |
ADC conversion result register (ADCRESULTx)¶
Offset: 0x18-0x24
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 12 | Reserved | 0x0 | R/W | Reserved |
11: 0 | ADCOUT | 0x000 | R/W | ADC conversion result |
Note: x=2,3,4,5, ADCRESULTx corresponds to the conversion result of channel x respectively
Channel 0 Sample Period Register (CH0PERIOD)¶
Offset: 0x38
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | CH0PERIOD | 0x0000 | R/W | Channel 0 Sampling period: (CH0PERIOD+1) * 512 |
Channel 1 Sampling Period Register (CH1PERIOD)¶
Offset: 0x3C
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | CH1PERIOD | 0x0000 | R/W | Channel 1 Sampling period: (CH1PERIOD+1) * 512 |
Channel 2 Sample Period Register (CH2PERIOD)¶
Offset: 0x40
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | CH2PERIOD | 0x0000 | R/W | Channel 2 Sampling period: (CH2PERIOD+1) * 512 |
Channel 3 Sample Period Register (CH3PERIOD)¶
Offset: 0x44
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | CH3PERIOD | 0x0000 | R/W | Channel 3 Sampling period: (CH3PERIOD+1) * 512 |
Channel 0 Lower Threshold Register (CH0MINVALUE)¶
Offset: 0x48
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | MINVALUE | 0x0000 | R/W | Lower threshold of channel 0 |
Channel 0 upper threshold register (CH0MAXVALUE)¶
Offset: 0x4C
Reset value: 0x0FFF
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | MAXVALUE | 0x0FFF | R/W | Upper threshold of channel 0 |
Channel 1 lower threshold register (CH1MINVALUE)¶
Offset: 0x50
Reset value: 0x0001
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | MINVALUE | 0x0001 | R/W | Lower threshold of channel 1 |
Channel 1 upper threshold register (CH1MAXVALUE)¶
Offset: 0x54
Reset value: 0x0FFF
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | MAXVALUE | 0x0FFF | R/W | Upper threshold of channel 1 |
Channel 2 Lower Threshold Register (CH2MINVALUE)¶
Offset: 0x58
Reset value: 0x0001
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15:00 | MINVALUE | 0x0001 | R/W | Lower threshold of channel 2 |
Channel 2 upper threshold register (CH2MAXVALUE)¶
Offset: 0x5C
Reset value: 0x0FFF
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | MAXVALUE | 0x0FFF | R/W | Upper threshold of channel 2 |
Channel 3 lower threshold register (CH3MINVALUE)¶
Offset: 0x60
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | MINVALUE | 0x0001 | R/W | Lower threshold of channel 3 |
Channel 3 upper threshold register (CH3MAXVALUE)¶
Offset: 0x64
Reset value: 0x0FFF
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | MAXVALUE | 0x0FFF | R/W | Upper threshold of channel 3 |
ADC Status Register (ADCSTAT)¶
Offset: 0x68
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 1 | Reserved | 0x0000 | RO | Reserved |
0 | PRDBSY | 0 | RO | Current ADC working status 0: ADC conversion completed, idle status 1: ADC working |
ADC control register a (ADCCTRLa)¶
Offset: 0x6C
Reset value: 0x00000000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
31:10 | Reserved | 0x0000 | R/W | Reserved |
9 | CH5MAXEN | 0 | R/W | CH5 Sampling Result Threshold Lower Limit Interrupt Enable 0: Off 1: On |
8 | CH4MAXEN | 0 | R/W | CH4 Sampling Result Threshold Lower Limit Interrupt Enable 0: Off 1: On |
7 | CH5MINEN | 0 | R/W | CH5 Sampling Result Threshold Lower Limit Interrupt Enable 0: Off 1: On |
6 | CH4MINEN | 0 | R/W | CH4 Sampling Result Threshold Lower Limit Interrupt Enable 0: Off 1: On |
5 | CH5EN | 0 | R/W | Channel 5 cycle monitoring enable 0: OFF 1: ON |
4 | CH4EN | 0 | R/W | Channel 4 cycle monitoring enable 0: Off 1: On |
3 | RSTN | 0 | R/W | ADC reset function 0: Start reset 1: Normal mode |
2 | SDIF | 0 | R/W | Analog sampling signal mode selection 0: Single ended mode 1: Differential mode, which is used in offset calibration mode |
1 | Reserved | 0x0000 | R/W | Reserved |
0 | DISH | 0 | R/W | Normal mode and offset calibration selection 0: Normal mode 1: Offset calibration mode |
Note 1: ADC is reset by default after power on. To use it, you must first set the RSTN bit to 1. At the same time, the ADC module has timing requirements when it is powered on and needs to keep the reset signal for a period of time after startup. Therefore, the following reset configuration register is added. When this configuration is 0, the RSTN signal is released after 6 ADC CLK cycles after the ADCEN signal is valid. When configured to other values, the RSTN signal is released after the configured value plus 6 ADC CLK cycles after the ADCEN signal is valid, so as to ensure normal ADC function
Note 2: ADC adds the offset calibration function to adapt to individual errors caused by chip production or environment. When using, set DISH and SDIF to 1 to short-circuit the internal VIP and VIN signals. At this time, calculate the difference between the sampling value read by the channel port corresponding to the ADC and the ideal conversion value 800H, use the difference as the offset value for calibration, and write it to the OFFSET bit of the ADC offset calibration register. Note that the value of this bit has a complement. If the value of this bit is set to 2F, 2F is the complement of - 17. At this time, when ADC sets DISH and SDIF to 0 and returns to the normal working mode, the sampling value will automatically calculate and subtract 17; If the value of this bit is set to 1A, 1A is the complement of 26. At this time, when ADC sets DISH and SDIF to 0 and returns to the normal working mode, the sampling value will be automatically calculated plus 26
ADC reset configuration register (ADCRSTN)¶
Offset: 0x70
Reset value: 0x00000000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
31:6 | Reserved | 0x0000 | R/W | Reserved |
5: 0 | ADCRSTN | 0 | R/W | Reset signal increases the number of cycles that remain low after the ADCEN signal is enabled |
ADC Offset Calibration Register (ADCOFFSET)¶
Offset: 0x74
Reset value: 0x00000000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
31:6 | Reserved | 0x0000 | R/W | Reserved |
5: 0 | OFFSET | 0 | R/W | Set ADC offset calibration value |
ADC Load Register (ADCLOADEN)¶
Offset: 0x78
Reset value: 0x00000000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
31:1 | Reserved | 0x0000 | R/W | Reserved |
0 | LOADEN | 0 | R/W | Enable loading signal, write 1 to load, and self clear after loading |
Note: This register needs to be configured with LOADEN bit as 0 before the ADC module is successfully reset to normal function, and the value of the register will take effect, and then the 0 th bit EN of the ADCCTRL control register can be configured_ ADC is 1, start ADC module to work
ADC Reset Status Register (ADCPWRRDY)¶
Offset: 0x7C
Reset value: 0x00000000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
31:1 | Reserved | 0x0000 | R | Reserved |
0 | PWRRDY | 0 | R | ADC reset release flag, highly effective |
Channel 4 Sample Period Register (CH4PERIOD)¶
Offset: 0x80
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 0 | CH4PERIOD | 0x0000 | R/W | Channel 4 Sampling period: (CH4PERIOD+1) * 512 |
Channel 5 Sample Period Register (CH5PERIOD)¶
Offset: 0x84
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15:00 | CH5PERIOD | 0x0000 | R/W | Channel 5 sampling period: (CH5PERIOD+1) * 512 |
Channel 4 Lower Threshold Register (CH4MINVALUE)¶
Offset: 0x88
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 12 | Reserved | 0x0 | R | Reserved |
11:0 | MINVALUE | 0x000 | R/W | Lower threshold of channel 4 |
Channel 4 upper threshold register (CH4MAXVALUE)¶
Offset: 0x8C
Reset value: 0x0FFF
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 12 | Reserved | 0x0 | R | Reserved |
11: 0 | MAXVALUE | 0xFFF | R/W | Upper threshold of channel 4 |
Channel 5 lower threshold register (CH5MINVALUE)¶
Offset: 0x90
Reset value: 0x0000
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 12 | Reserved | 0x0 | R | Reserved |
11: 0 | MINVALUE | 0x000 | R/W | Lower threshold of channel 5 |
Channel 5 upper threshold register (CH5MAXVALUE)¶
Offset: 0x94
Reset value: 0x0FFF
Bit Field | Name | Reset Value | Type | Description |
---|---|---|---|---|
15: 12 | Reserved | 0x0 | R | Reserved |
11: 0 | MAXVALUE | 0xFFF | R/W | Upper threshold of channel 5 |