Information
Note
Hexadecimal values are designated by a preceding 0x, binary
values designated by a preceding %, and decimal values have
no preceding character.
31.5.1 ADC module initialization example
This section provides details about the ADC module initialization.
31.5.1.1 Initialization sequence
Before the ADC module can be used to complete conversions, an initialization procedure
must be performed. A typical sequence is as follows:
1. Calibrate the ADC by following the calibration instructions in Calibration function.
2. Update the configuration register (CFG) to select the input clock source and the
divide ratio used to generate the internal clock, ADCK. This register is also used for
selecting sample time and low-power configuration.
3. Update status and control register 2 (SC2) to select the conversion trigger (hardware
or software) and compare function options, if enabled.
4. Update status and control register 3 (SC3) to select whether conversions will be
continuous or completed only once (ADCO) and to select whether to perform
hardware averaging.
5. Update the status and control register (SC1:SC1n) to select whether conversions will
be single-ended or differential and to enable or disable conversion complete
interrupts. Also, select the input channel on which to perform conversions.
31.5.1.2 Pseudo-code example
In this example, the ADC module is set up with interrupts enabled to perform a single 10-
bit conversion at low power with a long sample time on input channel 1, where the
internal ADCK clock is derived from the bus clock divided by 1.
CFG1 = 0x98 (%10011000)
Bit 7 ADLPC 1 Configures for low power (lowers maximum clock speed.
Bit 6:5 ADIV 00 Sets the ADCK to the input clock รท 1.
Bit 4 ADLSMP 1 Configures for long sample time.
Initialization information
K20 Sub-Family Reference Manual, Rev. 2, Feb 2012
624 Freescale Semiconductor, Inc.
