12.4. ADC and Temperature Sensor

RP2350 has an internal analogue-digital converter (ADC) with the following features:

Figure 107 shows the arrangement of ADC channels in the QFN-60 package. Figure 108 shows the same for QFN-80.

Figure 107. ADC Connection Diagram for QFN-60. This package features four external ADC inputs (0 through 3), on Bank 0 GPIOs 26 through 29. The internal temperature sensor connects to a fifth channel (channel 4). This is functionally the same ADC arrangement as RP2040, although the underlying hardware is different, to support the additional channels on QFN-80.

ADC Connection Diagram for QFN-60 package showing four external ADC inputs (0-3) and an internal temperature sensor (4) connected to the ADC block.

The diagram illustrates the ADC connection for the QFN-60 package. It shows four external ADC inputs (0 through 3) connected to Bank 0 GPIOs 26 through 29. Each input is connected to an 'Analogue input' and a 'Digital pad'. The internal temperature sensor connects to channel 4. The ADC block is connected to the 'ain_sel' bus, which selects the input for the ADC.

graph LR
    subgraph GPIOs [Bank 0 GPIOs]
        direction TB
        GPIO26[GPIO[26]]
        GPIO27[GPIO[27]]
        GPIO28[GPIO[28]]
        GPIO29[GPIO[29]]
    end

    subgraph Inputs [ADC Inputs]
        direction TB
        AI0[Analogue input 0]
        AI1[Analogue input 1]
        AI2[Analogue input 2]
        AI3[Analogue input 3]
        AI4[Analogue input 4]
    end

    subgraph Pads [Digital pads]
        direction TB
        DP0[Digital pad 0]
        DP1[Digital pad 1]
        DP2[Digital pad 2]
        DP3[Digital pad 3]
    end

    subgraph Sensors [Sensors]
        direction TB
        TS[Temperature Sensor on chip]
    end

    subgraph ADC [ADC]
        direction TB
        AI0 --- ADC
        AI1 --- ADC
        AI2 --- ADC
        AI3 --- ADC
        AI4 --- ADC
    end

    GPIO26 --- AI0
    GPIO26 --- DP0
    GPIO27 --- AI1
    GPIO27 --- DP1
    GPIO28 --- AI2
    GPIO28 --- DP2
    GPIO29 --- AI3
    GPIO29 --- DP3
    TS --- AI4

    AI0 --- ain_sel[ain_sel 0]
    AI1 --- ain_sel[ain_sel 1]
    AI2 --- ain_sel[ain_sel 2]
    AI3 --- ain_sel[ain_sel 3]
    AI4 --- ain_sel[ain_sel 4]
  
ADC Connection Diagram for QFN-60 package showing four external ADC inputs (0-3) and an internal temperature sensor (4) connected to the ADC block.

Figure 108. ADC Connection Diagram for QFN-80. This package features eight external ADC inputs (0 through 7), on Bank 0 GPIOs 40 through 47. The internal temperature sensor connects to a ninth channel (channel 8). Like in QFN-60, each ADC input shares a package pin with a digital Bank 0 GPIO: generally the digital functions are disabled when the ADC is in use.

ADC Connection Diagram for QFN-80. The diagram shows a vertical bus labeled 'ain_sel' with pins 0 through 8. Pins 0-7 are connected to external ADC inputs, each sharing a package pin with a digital Bank 0 GPIO (GPIO[40] through GPIO[47]). Each input has an 'Analogue input' and a 'Digital pad' (indicated by a dashed box). Pin 8 is connected to an internal 'Temperature Sensor (on chip)'. A block labeled 'ADC' is connected to the bus between pins 4 and 5.

The diagram illustrates the ADC connection for the QFN-80 package. It features a vertical bus labeled 'ain_sel' with pins 0 through 8. Pins 0 through 7 are connected to external ADC inputs, each sharing a package pin with a digital Bank 0 GPIO (GPIO[40] through GPIO[47]). Each input has an 'Analogue input' and a 'Digital pad' (indicated by a dashed box). Pin 8 is connected to an internal 'Temperature Sensor (on chip)'. A block labeled 'ADC' is connected to the bus between pins 4 and 5.

ADC Connection Diagram for QFN-80. The diagram shows a vertical bus labeled 'ain_sel' with pins 0 through 8. Pins 0-7 are connected to external ADC inputs, each sharing a package pin with a digital Bank 0 GPIO (GPIO[40] through GPIO[47]). Each input has an 'Analogue input' and a 'Digital pad' (indicated by a dashed box). Pin 8 is connected to an internal 'Temperature Sensor (on chip)'. A block labeled 'ADC' is connected to the bus between pins 4 and 5.

When using an ADC input shared with a GPIO pin, always disable the pin’s digital functions by setting IE low and OD high in the pin’s pad control register. See Section 9.11.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.8 V, the voltage on the ADC inputs should not exceed 1.8 V + 10% even if ADC_AVDD is powered at 3.3 V. Voltages greater than IOVDD will result in leakage currents through the ESD protection diodes. See Section 14.9, “Electrical specifications” for details.

12.4.1. Changes from RP2040

12.4.2. ADC controller

A digital controller manages the details of operating the RP2350 ADC, and provides additional functionality:

12.4.2.1. Channel connections

The ADC channels are connected to the following GPIOs in QFN-60

Table 1118. ADC channel connections on QFN-60

ChannelConnection
0GPIO[26]
1GPIO[27]
2GPIO[28]
3GPIO[29]
4Temperature Sensor

The ADC channels are connected to the following GPIOs in QFN-80

Table 1119. ADC channel connections on QFN-80

ChannelConnection
0GPIO[40]
1GPIO[41]
2GPIO[42]
3GPIO[43]
4GPIO[44]
5GPIO[45]
6GPIO[46]
7GPIO[47]
8Temperature Sensor

12.4.3. SAR ADC

The Successive Approximation Register Analogue to Digital Converter (SAR ADC) is a combination of digital controller and analogue circuit as shown in Figure 109 and Figure 110 .

Figure 109. SAR ADC
Block diagram QFN-60

Block diagram of the SAR ADC for the QFN-60 package. The diagram shows an external SAR controller connected to an internal ADC block. The controller has inputs conv_ready, conv_start, and conv_done, and outputs result_dout and conv_error. The internal ADC block contains a Sample and hold, DAC, and Comparator. It is controlled by sar_sample, sar_compare_divis, SAR control signals, sar_comp_enable, and sar_comp_result. The input is an analogue in with a 4-bit selector ain_sel <2:0> and a 4-bit input ain <4:0>.
Block diagram of the SAR ADC for the QFN-60 package. The diagram shows an external SAR controller connected to an internal ADC block. The controller has inputs conv_ready, conv_start, and conv_done, and outputs result_dout and conv_error. The internal ADC block contains a Sample and hold, DAC, and Comparator. It is controlled by sar_sample, sar_compare_divis, SAR control signals, sar_comp_enable, and sar_comp_result. The input is an analogue in with a 4-bit selector ain_sel <2:0> and a 4-bit input ain <4:0>.

Figure 110. SAR ADC
Block diagram QFN-80

Block diagram of the SAR ADC for the QFN-80 package. The diagram is similar to Figure 109 but with an 8-bit input. The internal ADC block has an 8-bit selector ain_sel <3:0> and an 8-bit input ain <8:0>. The rest of the internal components (Sample and hold, DAC, Comparator) and the external SAR controller are the same as in Figure 109.
Block diagram of the SAR ADC for the QFN-80 package. The diagram is similar to Figure 109 but with an 8-bit input. The internal ADC block has an 8-bit selector ain_sel <3:0> and an 8-bit input ain <8:0>. The rest of the internal components (Sample and hold, DAC, Comparator) and the external SAR controller are the same as in Figure 109.

The ADC requires a 48 MHz clock ( clk_adc), which could come from the USB PLL. Capturing a sample takes 96 clock cycles ( \( 96 \times 1/48 \text{ MHz} = 2 \mu\text{s} \) per sample (500 kS/s). The clock must be set up correctly before enabling the ADC.

When 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.

To save power, you can disable the ADC at any time by clearing CS.EN. CS.EN does not enable the temperature sensor bias source; it is controlled separately, see Section 12.4.6 for details.

The ADC input is capacitive. When sampling, the ADC places about 1pF across the input. Packaging, PCB routing, and other external factors introduce additional capacitance. The effective impedance, even when sampling at 500 kS/s, is over 100 kΩ. DC measurements have no need to buffer.

12.4.3.1. One-shot sample

To select an ADC input, write to CS.AINSEL:

Switching AINSEL requires no settling time.

Write a 1 to CS.START_ONCE to 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.

12.4.3.2. Free-running sampling

When CS.START_MANY is set, the ADC automatically starts new conversions at regular intervals. The most recent conversion result is always available in RESULT, but for IRQ or DMA-driven streaming of samples, you must enable the ADC FIFO (Section 12.4.3.4).

By default ( DIV = 0), new conversions start immediately after the previous conversion finishes, producing a new sample every 96 cycles. At a clock frequency of 48 MHz, this produces 500 kS/s.

Set DIV.INT to a positive value n to trigger the ADC once per n + 1 cycles. 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 runs the ADC at 1 kS/s, if running from a 48 MHz clock.

The pacing timer supports fractional-rate division (first order delta sigma). When setting DIV.FRAC to a non-zero value, the ADC starts a new conversion once per \( 1 + \text{INT} + \frac{\text{FRAC}}{256} \) cycles on average, by changing the sample interval between INT + 1 and INT + 2.

12.4.3.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 automatically cycles to the next input whose corresponding bit is set in RROBIN.

To disable the round-robin sampling feature, write 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 samples channels in the following order:

  1. 1. Channel 0
  2. 2. Channel 1
  3. 3. Channel 2
  4. 4. Channel 1
  5. 5. Channel 2
  6. 6. Channel 1
  7. 7. Channel 2

The ADC continues to sample channels 1 and 2 indefinitely.

i NOTE

The initial value of AINSEL does not need to correspond with a set bit in RROBIN.

12.4.3.4. Sample FIFO

You can read ADC samples directly from the RESULT register or store them in a local 8-entry FIFO and read out from FIFO. Use the FCS register to control FIFO operation.

When FCS.EN is set, the ADC writes each conversion result to the FIFO. A software interrupt handler or the RP2350 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. When the FIFO is full, the current FIFO contents do not change, so any conversions that complete during this time are lost.

Two flags control the data written to the FIFO by the ADC:

Conversion errors indicate that the comparison of one or more bits failed to complete in the time allowed. Conversion errors are typically caused by comparator metastability: the closer to the comparator threshold the input signal is, the longer it takes to make a decision. The higher the comparator gain, the lower the probability of conversion errors.

Warning icon CAUTION

Because conversion errors produce undefined results, you should always discard samples that contain conversion errors.

12.4.3.5. DMA

The RP2350 DMA (Section 12.6) 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. Before you can use the DMA to fetch ADC samples, you must:

Once the ADC is suitably configured, start the DMA channel first, then the ADC conversion via CS.START_MANY . Once the DMA completes, you can halt the ADC if you are finished sampling, or promptly start a new DMA transfer before the FIFO fills up. After clearing CS.START_MANY to halt the ADC, software should poll CS.READY to make sure the last conversion has finished, then drain any stray samples from the FIFO.

12.4.3.6. Interrupts

Use INTE to generate an interrupt when the FIFO level reaches a threshold defined in FCS.THRESH .

Use INTS to read the interrupt status. To clear the interrupt, drain the FIFO to a level lower than FCS.THRESH .

12.4.3.7. Supply

RP2350 separates the ADC supply out on its own pin to allow noise filtering.

12.4.4. ADC ENOB

ADC ENOB details are shown in Table 1438 .

12.4.5. INL and DNL

Details to follow.

12.4.6. Temperature sensor

The temperature sensor measures the \( V_{be} \) voltage of a biased bipolar diode, connected to the fifth ADC channel ( \( A_{INSEL}=4 \) ) on QFN-60 or the ninth ADC channel ( \( A_{INSEL}=8 \) ) on QFN-80. Typically, \( V_{be} = 0.706\text{ V} \) at \( 27\text{ }^{\circ}\text{C} \) , with a slope of \( -1.721\text{ mV per degree} \) . Therefore the temperature in \( ^{\circ}\text{C} \) can be approximated as follows:

\[ T = 27 - \frac{(ADC\_voltage - 0.706)}{0.001721} \]

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\text{ }\mu\text{A} \) .

i NOTE

The on board temperature sensor is very sensitive to errors in reference voltage. At \( 3.3\text{ V} \) , a value of 891 returned by the ADC corresponds to a temperature of \( 20.1^{\circ}\text{C} \) . At a reference voltage 1% lower than \( 3.3\text{ V} \) , the same reading of 891 correspond to a temperature of \( 24.3^{\circ}\text{C} \) : a temperature change of over \( 4^{\circ}\text{C} \) . To improve the accuracy of the internal temperature sensor, consider adding an external reference voltage.

12.4.7. List of registers

The ADC registers start at a base address of 0x400a0000(defined as ADC_BASE in SDK).

Table 1120. List of ADC registers

Offset 0x42fc8 0x42fcc 0x42fd0 0x42fd4 0x42fd8Name DEVID DEVTYPE PIDR4 PIDR5 PIDR6Info Device Configuration register Device Type Identifier register CoreSight Periperal ID4 CoreSight Periperal ID5 CoreSight Periperal ID6
The temperature sensor measures theVbe voltage of a biased bipolar diode, connected to the fifth ADC channel (
AINSEL=4) on QFN-60 or the ninth ADC channel (AINSEL =8) on QFN-80. Typically, Vbe = 0.706 V at 27 °C, with a slope of
As theVbe and the Vbe be required if accurate measurements are required.slope can vary over the temperature range, and from device to device, some user calibration may
The temperature sensor’s bias source must be enabled before use, via CS .TS_EN. This increases current consumption
on ADC_AVDD  NOTEby approximately 40 μA.
12.4.7. List of registers The ADC registers start at a base address of0x400a0000 (defined as ADC_BASE in SDK).
Offset ADC registersNameInfo
0x00CSADC Control and Status
0x04RESULTResult of most recent ADC conversion
0x08FCSFIFO control and status
0x0cFIFOConversion result FIFO
0x10DIVClock divider. If non-zero, CS_START_MANY will start conversions
0x14INTRTotal period is 1 + INT + FRAC / 256 Raw Interrupts
0x18INTEInterrupt Enable
0x1cINTFInterrupt Force
0x20INTSInterrupt status after masking & forcing
12.4. ADC and Temperature Sensor 12.4. ADC and Temperature Sensor1073

ADC: CS Register

Offset: 0x00

Description

ADC Control and Status

Table 1121. CS Register

Bits 31:0 Bits 31:0 Bits 31:28column_2Description Description Input value for GPIO0…31. Description QSPI_SD : Input value on QSPI SD0 (MOSI), SD1 (MISO), SD2 and SD3 pinsType RO Type RO Type ROReset - Reset 0x00000000 Reset 0x0
31:25Reserved.--
24:16RROBIN: Round-robin sampling. 1 bit per channel. Set all bits to 0 to disable. fashion.RW0x000
15:12AINSEL: Select analog mux input. Updated automatically in round-robin mode. This is corrected for the package option so only ADC channels which are bonded are available, and in the correct orderRW0x0
11Reserved.--
10ERR_STICKY clear.: Some past ADC conversion encountered an error. Write 1 toWC0x0
9ERR: The most recent ADC conversion encountered an error; result is undefined or noisy.RO0x0
8READY: 1 if the ADC is ready to start a new conversion. Implies any previous conversion has completed. 0 whilst conversion in progress.RO0x0
7:4Reserved.--
3START_MANY: Continuously perform conversions whilst this bit is 1. A new conversion will start immediately after the previous finishes.RW0x0
2START_ONCE: Start a single conversion. Self-clearing. Ignored if start_many is asserted.SC0x0
1TS_EN: Power on temperature sensor. 1 - enabled. 0 - disabled.RW0x0
0EN : Power on ADC and enable its clock.RW0x0
Bits: 0x04 DescriptionTypeReset
31:12Reserved.--
11:0Result of most recent ADC conversionRO0x000

ADC: RESULT Register

Offset: 0x04

Table 1122. RESULT Register

ADC: FCS Register

Offset: 0x08

Description

FIFO control and status

Table 1123. FCS Register

BitsDescriptionTypeReset
31:28Reserved.--
27:24THRESH : DREQ/IRQ asserted when level >= thresholdRW0x0
23:20Reserved.--
19:16LEVEL : The number of conversion results currently waiting in the FIFORO0x0
15:12Reserved.--
11OVER : 1 if the FIFO has been overflowed. Write 1 to clear.WC0x0
10UNDER : 1 if the FIFO has been underflowed. Write 1 to clear.WC0x0
9FULLRO0x0
8EMPTYRO0x0
7:4Reserved.--
3DREQ_EN : If 1: assert DMA requests when FIFO contains dataRW0x0
2ERR : If 1: conversion error bit appears in the FIFO alongside the resultRW0x0
1SHIFT : If 1: FIFO results are right-shifted to be one byte in size. Enables DMA to byte buffers.RW0x0
0EN : If 1: write result to the FIFO after each conversion.RW0x0

ADC: FIFO Register

Offset: 0x0c

Description

Conversion result FIFO

Table 1124. FIFO Register

BitsDescriptionTypeReset
31:16Reserved.--
15ERR : 1 if this particular sample experienced a conversion error. Remains in the same location if the sample is shifted.RF-
14:12Reserved.--
11:0VALRF-

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 + INT + FRAC / 256

Table 1125. DIV Register

BitsDescriptionTypeReset
31:24Reserved.--
23:8INT : Integer part of clock divisor.RW0x0000
7:0FRAC : Fractional part of clock divisor. First-order delta-sigma.RW0x00

ADC: INTR Register

Offset: 0x14

Description

Raw Interrupts

Table 1126. INTR Register

BitsDescriptionTypeReset
31:1Reserved.--
0FIFO: Triggered when the sample FIFO reaches a certain level.
This level can be programmed via the FCS_THRESH field.
RO0x0

ADC: INTE Register

Offset: 0x18

Description

Interrupt Enable

Table 1127. INTE Register

BitsDescriptionTypeReset
31:1Reserved.--
0FIFO: Triggered when the sample FIFO reaches a certain level.
This level can be programmed via the FCS_THRESH field.
RW0x0

ADC: INTF Register

Offset: 0x1c

Description

Interrupt Force

Table 1128. INTF Register

BitsDescriptionTypeReset
31:1Reserved.--
0FIFO: Triggered when the sample FIFO reaches a certain level.
This level can be programmed via the FCS_THRESH field.
RW0x0

ADC: INTS Register

Offset: 0x20

Description

Interrupt status after masking & forcing

Table 1129. INTS Register

BitsDescriptionTypeReset
31:1Reserved.--
0FIFO: Triggered when the sample FIFO reaches a certain level.
This level can be programmed via the FCS_THRESH field.
RO0x0