NOTICE: This website will be shut down in the near future. Product content has moved to Forum content and FAQs have been moved to We encourage you to create a user account on to use the new community forums and access NXP microcontroller content. We greatly appreciate your contributions and look forward to seeing you at our new web location.


LPCXpresso LPC1227 ADC pin high

2 replies [Last post]
Joined: 2012-04-12
Posts: 28

Hey guys,

I am using the ADC example program for the LPC1227 board. I am printing the value of the ADC to the console of Eclipse.

However, when I don't have an input into the AD0 pin it is read as 1023 or high. Is this correct? If so, how do I remedy this to give me the correct reference. I do not want my input to be inverted.

Furthermore, how would I go about changing an individual bit for a GPIO pin? If i want to toggle a pin, would i do

LPC_IOCON->PIO0_7 |= 0 << 6;


Your rating: None

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-12-02
Posts: 643


A low level on an ADC channel returns a value of 0, a high level on an ADC channel returns 1023, so there's no inversion.
Most probably the AD0 pin is tied high by the internal pull-up resistor. When connecting a low-impedance source to the AD0 pin, you will get correct readings and will not notice this resistor anymore.
If you still want to disable the pull-up resistor, add the following code to your initalization:
LPC_IOCON->R_PIO0_30 &= ~(1<<4); /* Disable pull-up resistor */

You can control an output pin like this:

LPC_GPIO0->DIR |= (1<<5); /* GPIO0_5 as output */
LPC_GPIO0->OUT &= ~(1<<5); /* clear GPIO0_5 */
LPC_GPIO0->OUT |= (1<<5); /* set GPIO0_5 */
LPC_GPIO0->OUT ^= (1<<5); /* toggle GPIO0_5 */

Kind regards,

- NXP European team -

- NXP European team -

Joined: 2013-12-15
Posts: 2

iam struggling hard since more than a week . to get a sample program wherein an ADC and timers are used , with their interrupts (irq handlers ) and typical initiatialization() functions for cortex-m0 lpc1224 (i think ...the most left-away series by the user

please can anyone post a link or upload a sample-code - wherein the ADC and timer IRQhandlers through NVIC is used.

a C code in which start-end-execution process well explained ...

i have hauled over usermanuals and datasheets but all in void and acheieved no clarity on this subject for example
1)how and when pending , priority , disable NVIC functions are used simaltaneously
2) what is to be written in ISR/IRQ_handlers and init() functions
; for ARM iam totally blank on this topic , as i have worked with PICs and AVR Mcus only.

please do the needful...hope u got my 'cry'

deeply grateful in advance Sad Sad(