Loading...
Searching...
No Matches
NXP QN908x ADC - Analog to Digital converter

NXP QN908x ADC driver.

NXP QN908x ADC driver.

This ADC is a differential sigma-delta ADC. There are 9 external signals named ADC0 to ADC7 and ADC_VREFI that can be connected to specific external GPIO pins. There are several combinations of measurements possible with the ADC module using these external signals as well as some internal signals, but not every combination is a possible input pair to the ADC.

The ADC block runs at either 4 MHz or 32 KHz from the high speed or low speed clock sources respective. An additional divisor is available to select some intermediate clock values. However, this is not the sample rate, since a single sample from adc_sample() requires multiple internal samples which are then filtered and decimated by the hardware, giving about 128 slower sample rate than the selected clock.

Each board-defined ADC line is configured with a single integer value which is the logic or of the following values:

The hardware resolution of the ADC data is always 23-bits signed, but smaller resolutions can be requested which will result in a smaller output value.

An internal temperature sensor is available and connected to the ADC when selecting ADC_CHANNEL_TEMP as the channel. In this case the returned value is still a number that represents the temperature dependent voltage level of the internal signal which then needs to be converted to a temperature by the application using calibration parameters. When using the internal temperature sensor, the 1.2V bandgap Vref is recommended with a Vinn of 1/2 Vref since the measured voltage is about 800 mV at room temperature.

A special microvolts (ADC_RES_UV) resolution value for adc_res_t is supported when using the internal 1.2 V bandgap as the reference voltage, in which case adc_sample will return the measured value in microvolts as a signed integer, with a max range of +/- 1.8 V when using the x1.5 Vref multiplier. This special resolution mode takes into account the factory calibration of the internal reference voltage for more accurate readings. In any other case, the return value is a signed integer with as many bits as resolution requested not including the sign bit. Note that the return value may be a negative when measuring a negative differential voltage between the plus and minus side of the input.

For example, if 8-bit resolution is requested for an ADC line where the channel connects the - side to Vinn configured as Vss, a maximum value of 255 can be returned when the + side level is as high as the Vref signal. However, a negative value of -255 is also possible if Vinn is configured as Vref and the + side level is as low as Vss.

ADC configuration example (for periph_conf.h)

static const adc_conf_t adc_config[] = {
/* Pin A11 to Vss, 1.8v Vref. */
/* Pin A10 to A11, 1.2V Vref. */
/* Temperature (in V) over to 0.6 V, 1.2 V Vref. */
/* Internal "battery monitor", Vcc/4 to Vss, 1.2V Vref. */
};
#define ADC_NUMOF ARRAY_SIZE(adc_config)
#define QN908X_ADC_CLOCK ADC_CLOCK_500K
#define ADC_VREF_GAIN_X15
ADC Vref x1.5 multiplier flag.
Definition periph_cpu.h:267
@ ADC_VINN_VREF_2
Use Vinn := 1/2 * Vref.
Definition periph_cpu.h:292
@ ADC_VINN_AVSS
Use Vinn := Vss.
Definition periph_cpu.h:293
@ ADC_CHANNEL_TEMP
Sample internal temperature.
Definition periph_cpu.h:240
@ ADC_CHANNEL_ADC6_ADC7
Sample ADC6 / ADC7.
Definition periph_cpu.h:231
@ ADC_CHANNEL_ADC7_VINN
Sample ADC7 / Vinn.
Definition periph_cpu.h:239
@ ADC_CHANNEL_VCC4_VINN
Sample 1/4 Vcc / Vinn.
Definition periph_cpu.h:241
ADC device configuration.
Definition periph_cpu.h:379