Content originally posted in LPCWare by melpel on Thu Mar 21 09:04:50 MST 2013
I've tried multiple methods of pion configuration, makes no difference. Also have gone back to reverify the pin configuration by reading back the PINSEL[n] registers.
One thing that is not clear is whether the PINMODE[n] and pin direction FIOxDIR registers require setting or not. I set them to no pull up/down just in case. Based on the PINSEL documentation this should be set automatically when selecting non-GPIO function.
Fault mode update: What I am seeing is 0x0FFF for input < 2V, stray values for 2- ~2.3V, and 0x0000 for Vin > 2.3V.
The clean code style:
configAdcPin(PORT0, 24, MODE1);// ADC0.1 on P0.24
configAdcPin(PORT0, 25, MODE1);// ADC0.2 on P0.25
configAdcPin(PORT0, 26, MODE1);// ADC0.3 on P0.26
configAdcPin(PORT1, 30, MODE3);// ADC0.4 on P1.30
configAdcPin(PORT1, 31, MODE3);// ADC0.5 on P1.31
configAdcPin(PORT0, 3, MODE2);// ADC0.6 on P0.3
configAdcPin(PORT0, 2, MODE2);// ADC0.7 on P0.2
And the brute force:
// 3. Set Pins
LPC_PINCON->PINSEL0 &= ~0x000000F0;/* P0.2~3, A0.6~7, function 10 */
LPC_PINCON->PINSEL0 |= 0x000000A0;
LPC_PINCON->PINSEL1 &= ~0x003FC000;/* P0.23~26, A0.0~3, function 01 */
LPC_PINCON->PINSEL1 |= 0x00154000;
LPC_PINCON->PINSEL3 |= 0xF0000000;/* P1.30~31, A0.4~5, function 11 */
/* No pull-up no pull-down (function 10) on these ADC pins. */
LPC_PINCON->PINMODE0 &= ~0x000000F0;
LPC_PINCON->PINMODE0 |= 0x000000A0;
LPC_PINCON->PINMODE1 &= ~0x003FC000;
LPC_PINCON->PINMODE1 |= 0x002A8000;
LPC_PINCON->PINMODE3 &= ~0xF0000000;
LPC_PINCON->PINMODE3 |= 0xA0000000;
No difference either way...