NOTICE: NXP has started migrating LPCWare.com to NXP.com. Many LPCware.com pages are being redirected to NXP.com. Please visit software and tools page for information on LPC microcontrollers.
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;
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 */
- NXP European team -
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 community...lol)
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 (