4.9. ADC and Temperature Sensor
RP2040 has an internal analogue-digital converter (ADC) with the following features:
- • SAR ADC (see Section 4.9.2 )
- • 500ksps (using an independent 48MHz clock)
- • 12-bit with 8.7 ENOB (see Section 4.9.3 )
- • Five input mux:
- ◦ Four inputs that are available on package pins shared with GPIO[29:26]
- ◦ One input is dedicated to the internal temperature sensor (see Section 4.9.5 )
- • Eight element receive sample FIFO
- • Interrupt generation
- • DMA interface (see Section 4.9.2.5 )
Figure 114. ADC
Connection Diagram

The diagram illustrates the ADC connection. On the left, four GPIO pins (GPIO[26], GPIO[27], GPIO[28], and GPIO[29]) are shown. Each pin has a dashed box containing an 'Analogue input' and a 'Digital pad'. The 'Analogue input' lines connect to a vertical bus labeled 'ain_sel' with values 0, 1, 2, and 3 respectively. A 'Temperature Sensor (on chip)' block connects to the 'ain_sel' bus at value 4. The 'ain_sel' bus then connects to the 'ADC' block on the right.
NOTE
When using an ADC input shared with a GPIO pin, the pin's digital functions must be disabled by setting IE low and OD high in the pin's pad control register. See Section 2.19.6.3, "Pad Control - User Bank" for details. The maximum ADC input voltage is determined by the digital IO supply voltage (IOVDD), not the ADC supply voltage (ADC_AVDD). For example, if IOVDD is powered at 1.8V, the voltage on the ADC inputs should not exceed 1.8V even if ADC_AVDD is powered at 3.3V. Voltages greater than IOVDD will result in leakage currents through the ESD protection diodes. See Section 5.5.3, "Pin Specifications" for details.
4.9.1. ADC controller
A digital controller manages the details of operating the RP2040 ADC, and provides additional functionality:
- • One-shot or free-running capture mode
- • Sample FIFO with DMA interface
- • Pacing timer (16 integer bits, 8 fractional bits) for setting free-running sample rate
- • Round-robin sampling of multiple channels in free-running capture mode
- • Optional right-shift to 8 bits in free-running capture mode, so samples can be DMA'd to a byte buffer in system memory
4.9.2. SAR ADC
The SAR ADC (Successive Approximation Register Analogue to Digital Converter) is a combination of digital controller, and analogue circuit as shown in Figure 115 .
Figure 115. SAR ADC Block diagram

The ADC requires a 48MHz clock (
clk_adc), which could come from the USB PLL. Capturing a sample takes 96 clock cycles (
\(
96 \times 1/48\text{MHz}
\)
) = 2µs per sample (500ksps). The clock must be set up correctly before enabling the ADC.
Once the ADC block is provided with a clock, and its reset has been removed, writing a 1 to
CS.EN will start a short internal power-up sequence for the ADC's analogue hardware. After a few clock cycles,
CS.READY will go high, indicating the ADC is ready to start its first conversion.
The ADC can be disabled again at any time by clearing
CS.EN, to save power.
CS.EN does
not
enable the temperature sensor bias source (see
Section 4.9.5
). This is controlled separately.
The ADC input is capacitive, and when sampling, it places about 1pF across the input (there will be additional capacitance from outside the ADC, such as packaging and PCB routing, to add to this). The effective impedance, even when sampling at 500ksps, is over 100kΩ, and for DC measurements there should be no need to buffer.
4.9.2.1. One-shot Sample
Writing a 1 to
CS.START_ONCE will immediately start a new conversion.
CS.READY will go low, to show that a conversion is currently in progress. After 96 cycles of
clk_adc,
CS.READY will go high. The 12-bit conversion result is available in
RESULT.
The ADC input to be sampled is selected by writing to
CS.AINSEL, any time before the conversion starts. An
AINSEL value of 0...3 selects the ADC input on GPIO 26...29.
AINSEL of 4 selects the internal temperature sensor.
i NOTE
No settling time is required when switching
AINSEL.
4.9.2.2. Free-running Sampling
When
CS.START_MANY is set, the ADC will automatically start new conversions at regular intervals. The most recent conversion result is always available in
RESULT, but for IRQ or DMA driven streaming of samples, the ADC FIFO must be enabled (
Section 4.9.2.4
).
By default (
DIV = 0), new conversions start immediately upon the previous conversion finishing, so a new sample is produced every 96 cycles. At a clock frequency of 48MHz, this produces 500ksps.
Setting
DIV.INT to some positive value
\(
n
\)
will trigger the ADC once per
\(
n + 1
\)
cycles, though the ADC ignores this if a conversion is currently in progress, so generally
\(
n
\)
will be
\(
\geq 96
\)
. For example, setting
DIV.INT to 47999 will run the ADC at 1ksps, if running from a 48MHz clock.
The pacing timer supports fractional-rate division (first order delta sigma). When setting
DIV.FRAC to a nonzero value,
the ADC will start a new conversion once per \( 1 + \text{INT} + \frac{\text{FRAC}}{256} \) cycles on average, by changing the sample interval between \( \text{INT} + 1 \) and \( \text{INT} + 2 \) .
4.9.2.3. Sampling Multiple Inputs
CS.RROBIN allows the ADC to sample multiple inputs, in an interleaved fashion, while performing free-running sampling. Each bit in RROBIN corresponds to one of the five possible values of CS.AINSEL . When the ADC completes a conversion, CS.AINSEL will automatically cycle to the next input whose corresponding bit is set in RROBIN .
The round-robin sampling feature is disabled by writing all-zeroes to CS.RROBIN .
For example, if AINSEL is initially 0, and RROBIN is set to 0x06 (bits 1 and 2 are set), the ADC will sample channels in the following order:
- 1. Channel 0
- 2. Channel 1
- 3. Channel 2
- 4. Channel 1
- 5. Channel 2
- 6. Channel 1...
i NOTE
The initial value of AINSEL does not need to correspond with a set bit in RROBIN .
4.9.2.4. Sample FIFO
The ADC samples can be read directly from the RESULT register, or stored in a local 8-entry FIFO and read out from FIFO . FIFO operation is controlled by the FCS register.
If FCS.EN is set, the result of each ADC conversion is written to the FIFO. A software interrupt handler or the RP2040 DMA can read this sample from the FIFO when notified by the ADC's IRQ or DREQ signals. Alternatively, software can poll the status bits in FCS to wait for each sample to become available.
If the FIFO is full when a conversion completes, the sticky error flag FCS.OVER is set. The current FIFO contents are not changed by this event, but any conversion that completes whilst the FIFO is full will be lost.
There are two flags that control the data written to the FIFO by the ADC:
- • FCS.SHIFT will right-shift the FIFO data to eight bits in size (i.e. FIFO bits 7:0 are conversion result bits 11:4). This is suitable for 8-bit DMA transfer to a byte buffer in memory, allowing deeper capture buffers, at the cost of some precision.
- • FCS.ERR will set the FIFO.ERR flag of each FIFO value, showing that a conversion error took place, i.e. the SAR failed to converge (see below)
CAUTION
Conversion errors produce undefined results, and the corresponding sample should be discarded. They indicate that the comparison of one or more bits failed to complete in the time allowed. Normally this is caused by comparator metastability, i.e. the closer to the comparator threshold the input signal is, the longer it will take to make a decision. The high gain of the comparator reduces the probability that no decision is made.
4.9.2.5. DMA
The RP2040 DMA (Section 2.5) can fetch ADC samples from the sample FIFO, by performing a normal memory-mapped read on the FIFO register, paced by the ADC_DREQ system data request signal. The following must be considered:
- • The sample FIFO must be enabled (FCS.EN) so that samples are written to it; the FIFO is disabled by default so that it does not inadvertently fill when the ADC is used for one-shot conversions.
- • The ADC's data request handshake (DREQ) must be enabled, via FCS.DREQ_EN.
- • The DMA channel used for the transfer must select the DREQ_ADC data request signal (Section 2.5.3.1).
- • The threshold for DREQ assertion (FCS.THRESH) should be set to 1, so that the DMA transfers as soon as a single sample is present in the FIFO. Note this is also the threshold used for IRQ assertion, so non-DMA use cases might prefer a higher value for less frequent interrupts.
- • If the DMA transfer size is set to 8 bits, so that the DMA transfers to a byte array in memory, FCS.SHIFT must also be set, to pre-shift the FIFO samples to 8 bits of significance.
- • If multiple input channels are to be sampled, CS.RROBIN contains a 5-bit mask of those channels (4 external inputs plus temperature sensor). Additionally CS.AINSEL must select the channel for the first sample.
- • The ADC sample rate (Section 4.9.2.2) should be configured before starting the ADC.
Once the ADC is suitably configured, the DMA channel should be started first, and the ADC conversion should be started second, via CS.START_MANY. Once the DMA completes, the ADC can be halted, or a new DMA transfer promptly started. After clearing CS.START_MANY to halt the ADC, software should also poll CS.READY to make sure the last conversion has finished, and then drain any stray samples from the FIFO.
4.9.2.6. Interrupts
An interrupt can be generated when the FIFO level reaches a configurable threshold FCS.THRESH. The interrupt output must be enabled via INTE.
Status can be read from INTS. The interrupt is cleared by draining the FIFO to a level lower than FCS.THRESH.
4.9.2.7. Supply
The ADC supply is separated out on its own pin to allow noise filtering.
4.9.3. ADC ENOB
The ADC was characterised and the ENOB of the ADC was measured. Testing was carried out at room temperature across silicon lots, with tests being done on 3 typical (tt) as well as 3 fast (ff) and 3 slow (ss) corner RP2040 devices. The typical, minimum, and maximum values in Table 566 reflect the silicon used in the testing.
Table 565. Parameters used during the testing.
| Parameter | Value |
|---|---|
| Sample rate | 250ksps |
| Parameter | Value |
|---|---|
| FFT window | 5 term Blackman-Harris |
| FFT bins | 4,096 |
| FFT averaging | none |
| Input level min | 1 |
| Input level max | 4,094 |
| Input frequency | 997Hz |
It should be noted that THD is normally calculated using the first 5 or 6 harmonics. However as INL/DNL errors (see Section 4.9.4 ) create more than this, the first 30 peaks are used. This makes the THD value slightly worse, but more representative of reality.
Table 566. Results for various parts tested (fast, slow, and typical).
| Min | Typical | Max | |
|---|---|---|---|
| THD 1 | -55.6dB | 55dB | -54.4dB |
| SNR | 60.9dB | 61.5dB | 62.0dB |
| SFDR | 59.2dB | 59.9dB | 60.5dB |
| SINAD | 53.6dB | 54.0dB | 54.6dB |
| ENOB | 8.6 | 8.7 | 8.8 |
1 As the INL creates a large number of harmonics, the highest 30 peaks were used. This is different from conventional calculations of THD.
! IMPORTANT
Testing was carried out using a board with a low-noise on-board voltage reference as, when characterising the ADC, it is important that there are no other noise sources affecting the measurements.
4.9.4. INL and DNL
Integral Non-Linearity (INL) and Differential Non-Linearity (DNL) are used to measure the error of the quantisation of the incoming signal that the ADC generates. In an ideal ADC the input-to-output transfer function should have a linear quantised transfer between the analogue input signal and the digitised output signal. The RP2040 ADC INL values for each binary result are shown in Figure 116 , illustrating that the error is a sawtooth rather than the expected curve.
Figure 116. ATE machine results for INL (RP2040).

Nominally an ADC moves from one digital value to the next digital value, colloquially expressed as “no missing codes”. However, if the ADC skips a value bin this would cause a spike in the Differential Non-Linearity (DNL) error. These types of error often only occur at specific codes due to the design of the ADC.
The RP2040 ADC has a DNL which is mostly flat, and below 1 LSB. However at four values — 512, 1536, 2560, and 3,584 — the ADC’s DNL error peaks, see Figure 117
Figure 117. ATE machine results for DNL (RP2040).

The INL and DNL errors come from an error in the scaling of some internal capacitors of the ADC. These capacitors are small in value (only tens of femto Farads) and at these very small values, chip simulation of these capacitors can deviate slightly from reality. If these capacitors had matched correctly, the ADCs performance could have been better.
These INL and DNL errors will somewhat limit the performance of the ADC dependent on use case (See Errata RP2040-E11 ).
4.9.5. Temperature Sensor
The temperature sensor measures the \( V_{be} \) voltage of a biased bipolar diode, connected to the fifth ADC channel (AINSEL=4). Typically, \( V_{be} = 0.706V \) at 27 degrees C, with a slope of \( -1.721mV \) per degree. Therefore the temperature can be approximated as follows:
As the \( V_{be} \) and the \( V_{be} \) slope can vary over the temperature range, and from device to device, some user calibration may be required if accurate measurements are required.
The temperature sensor’s bias source must be enabled before use, via CS.TS_EN . This increases current consumption on ADC_AVDD by approximately 40µA.
Image: Note icon
NOTEThe on board temperature sensor is very sensitive to errors in the reference voltage. If the ADC returns a value of 891 this would correspond to a temperature of 20.1°C. However if the reference voltage is 1% lower than 3.3V then the same reading of 891 would correspond to 24.3°C. You would see a change in temperature of over 4°C for a small 1% change in reference voltage. Therefore if you want to improve the accuracy of the internal temperature sensor it is worth considering adding an external reference voltage.
Image: Note icon
NOTEThe INL errors, see Section 4.9.4 , aren’t in the usable temperature range of the ADC.
4.9.6. List of Registers
The ADC registers start at a base address of
0x4004c000(defined as
ADC_BASE
in SDK).
Table 567. List of ADC registers
| Offset | Name | Info |
|---|---|---|
| 0x00 | CS | ADC Control and Status |
| 0x04 | RESULT | Result of most recent ADC conversion |
| 0x08 | FCS | FIFO control and status |
| 0x0c | FIFO | Conversion result FIFO |
| 0x10 | DIV | Clock divider. If non-zero, CS_START_MANY will start conversions at regular intervals rather than back-to-back. The divider is reset when either of these fields are written. Total period is 1 + INT + FRAC / 256 |
| 0x14 | INTR | Raw Interrupts |
| 0x18 | INTE | Interrupt Enable |
| 0x1c | INTF | Interrupt Force |
| 0x20 | INTS | Interrupt status after masking & forcing |
ADC: CS Register
Offset: 0x00
Description
ADC Control and Status
Table 568. CS Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:21 | Reserved. | - | - |
| 20:16 | RROBIN
: Round-robin sampling. 1 bit per channel. Set all bits to 0 to disable. Otherwise, the ADC will cycle through each enabled channel in a round-robin fashion. The first channel to be sampled will be the one currently indicated by AINSEL. AINSEL will be updated after each conversion with the newly-selected channel. | RW | 0x00 |
| 15 | Reserved. | - | - |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 14:12 | AINSEL : Select analog mux input. Updated automatically in round-robin mode. | RW | 0x0 |
| 11 | Reserved. | - | - |
| 10 | ERR_STICKY : Some past ADC conversion encountered an error. Write 1 to clear. | WC | 0x0 |
| 9 | ERR : The most recent ADC conversion encountered an error; result is undefined or noisy. | RO | 0x0 |
| 8 | READY
: 1 if the ADC is ready to start a new conversion. Implies any previous conversion has completed. 0 whilst conversion in progress. | RO | 0x0 |
| 7:4 | Reserved. | - | - |
| 3 | START_MANY : Continuously perform conversions whilst this bit is 1. A new conversion will start immediately after the previous finishes. | RW | 0x0 |
| 2 | START_ONCE : Start a single conversion. Self-clearing. Ignored if start_many is asserted. | SC | 0x0 |
| 1 | TS_EN : Power on temperature sensor. 1 - enabled. 0 - disabled. | RW | 0x0 |
| 0 | EN
: Power on ADC and enable its clock. 1 - enabled. 0 - disabled. | RW | 0x0 |
ADC: RESULT Register
Offset: 0x04
Table 569. RESULT Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:12 | Reserved. | - | - |
| 11:0 | Result of most recent ADC conversion | RO | 0x000 |
ADC: FCS Register
Offset: 0x08
Description
FIFO control and status
Table 570. FCS Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:28 | Reserved. | - | - |
| 27:24 | THRESH : DREQ/IRQ asserted when level >= threshold | RW | 0x0 |
| 23:20 | Reserved. | - | - |
| 19:16 | LEVEL : The number of conversion results currently waiting in the FIFO | RO | 0x0 |
| 15:12 | Reserved. | - | - |
| 11 | OVER : 1 if the FIFO has been overflowed. Write 1 to clear. | WC | 0x0 |
| 10 | UNDER : 1 if the FIFO has been underflowed. Write 1 to clear. | WC | 0x0 |
| 9 | FULL | RO | 0x0 |
| 8 | EMPTY | RO | 0x0 |
| 7:4 | Reserved. | - | - |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 3 | DREQ_EN : If 1: assert DMA requests when FIFO contains data | RW | 0x0 |
| 2 | ERR : If 1: conversion error bit appears in the FIFO alongside the result | RW | 0x0 |
| 1 | SHIFT : If 1: FIFO results are right-shifted to be one byte in size. Enables DMA to byte buffers. | RW | 0x0 |
| 0 | EN : If 1: write result to the FIFO after each conversion. | RW | 0x0 |
ADC: FIFO Register
Offset: 0x0c
Description
Conversion result FIFO
Table 571. FIFO Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:16 | Reserved. | - | - |
| 15 | ERR : 1 if this particular sample experienced a conversion error. Remains in the same location if the sample is shifted. | RF | - |
| 14:12 | Reserved. | - | - |
| 11:0 | VAL | RF | - |
ADC: DIV Register
Offset: 0x10
Description
Clock divider. If non-zero, CS_START_MANY will start conversions at regular intervals rather than back-to-back.
The divider is reset when either of these fields are written.
Total period is \( 1 + \text{INT} + \text{FRAC} / 256 \)
Table 572. DIV Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:24 | Reserved. | - | - |
| 23:8 | INT : Integer part of clock divisor. | RW | 0x0000 |
| 7:0 | FRAC : Fractional part of clock divisor. First-order delta-sigma. | RW | 0x00 |
ADC: INTR Register
Offset: 0x14
Description
Raw Interrupts
Table 573. INTR Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:1 | Reserved. | - | - |
| 0 | FIFO:
Triggered when the sample FIFO reaches a certain level. This level can be programmed via the FCS_THRESH field. | RO | 0x0 |
ADC: INTE Register
Offset: 0x18
Description
Interrupt Enable
Table 574. INTE Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:1 | Reserved. | - | - |
| 0 | FIFO:
Triggered when the sample FIFO reaches a certain level. This level can be programmed via the FCS_THRESH field. | RW | 0x0 |
ADC: INTF Register
Offset: 0x1c
Description
Interrupt Force
Table 575. INTF Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:1 | Reserved. | - | - |
| 0 | FIFO:
Triggered when the sample FIFO reaches a certain level. This level can be programmed via the FCS_THRESH field. | RW | 0x0 |
ADC: INTS Register
Offset: 0x20
Description
Interrupt status after masking & forcing
Table 576. INTS Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:1 | Reserved. | - | - |
| 0 | FIFO:
Triggered when the sample FIFO reaches a certain level. This level can be programmed via the FCS_THRESH field. | RO | 0x0 |