Content originally posted in LPCWare by andypevy on Wed May 06 08:40:11 MST 2015
Hi, Looking at the spec relating to the ADC Input pins, it seems to indicate that I should use
Pin Function 0 to select the ADC input.
However looking at the demo code in both the NXP provided examples and the html
documantation, it says :-
Basic driver use model
Follow these basic steps to setup and use the ADC driver.
Step 1 : Perform setup prior to using ROM
The ROM drivers don't setup clocking, pin muxing, etc. Setup the pin muxing, peripheral clocking, and reset the peripheral prior to calling the ROM functions. Before using the driver, perform setup functions the ROM driver doesn't perform. These include enabling the clock, resetting the peripheral, and setting up any pin muxing and pin mode to analog needed for the peripheral. The setup for this may vary per software platform used. The setup code below is from LPCOpen.
/* Below code sets 12-ADC Pins to Analog mode, pins to inactive, neither pull-up nor pull-down. */
/* A typical application will enable only channels that are used */
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 29, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN); /* ADC CH0 */
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 30, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_ANALOG_EN); /* ADC CH1 */
Chop here for brevity...
/* Power up ADC and enable ADC base clock */
Chip_SYSCTL_PowerUp(PDRUNCFG_PD_ADC0 | PDRUNCFG_PD_VD7_ENA | PDRUNCFG_PD_VREFP_SW);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_ADC0);
Which specifically selects IOCON_FUNC1 rather than 0.
IOCON_FUNC1 is specified as R - Reserved in the Pin Description in UM10850 chapter 7 .
All the other settings make sense.
So which is correct, the code or the Spec ??.
Thanks,
Andy