Specifications

Built-in functions readAdc():
The ADC on an MC13224 returns a 12-bit value (0x0000 to 0x0FFF, 0 to 4096), with 8 to 9 bits of
precision. Most other SNAP platforms return 10-bit values from their ADCs. In order to scale these
values to match, you can shift right two bits or divide by four, without any loss of precision.
On an MC13224, a call to readAdc() clears any state set on a pin by the setPinDir() function
to define the pin as either a digital input or output. If your design requirements mandate that a pin be
able to function as both an ADC and either a digital input or output, you must use setPinDir() to
define the digital state of the pin between readAdc() calls.
The following table indicates which “virtual” channel to use, depending on which voltage reference
you want to use, and which analog channel you want to read.
For example, if you wanted to take a reading from the ADC3 pin and use the external VREF1 pin as a
reference voltage, you would call readAdc(12).
ADC signal GPIO pin VCC Channel VREF1 Channel VREF2 Channel
ADC0 30 0 9 18
ADC1 31 1 10 19
ADC2 32 2 11 20
ADC3 33 3 12 21
ADC4 34 4 13 22
ADC5 35 5 14 23
ADC6 36 6 15 24
ADC7 37 7 16 25
Battery (internal) 8 17 N/A
Built-in functions setPinDir():
The state of a pin set using the setPinDir() function is lost on GPIO_30 through GPIO_37 if you
perform a readAdc() function on the pin. If your design requirements mandate that a pin be able to
function as both an ADC and either a digital input or output, you must use setPinDir() to define
the digital state of the pin between readAdc() calls.
Similarly, using setPinDir() on GPIO_38 through GPIO_41 removes those pins’ abilities to
function as VREF pins for the ADCs. If your design requirements mandate that a pin be able to
function as both an ADC VREF and either a digital input or output, you must use setPinDir() to
define the digital state of the pin before reading from or writing to it, and then use pokes to reset
keepers on the pins before making any use of the pin as a VREF. Please reference the Freescale
MC1322x reference manual for details on the GPIO_PAD_KEEP1 register.
SNAP Reference Manual Document Number 600-0007K Page 181 of 202