hey
i am using LPC 2148. and configured the hardware for taking the analog signal at P0.28 which is ADC0 channel 1.
i am using following code but the output stays 0 or 1023 only.
my hardware connections are verified with several ready made boards and kits for the same controller..
kindly check and help for my problem..
thanks
#include<lpc214x.h> #include<stdio.h> //VPB clock 30Mhz void delay(int); extern long val,stat,s; extern long adc_val; int main() { serial_init(); clear_arrays(); adc_init(); //printf("MISSAR SYSTEMS\n\n"); while(1) { adc_read(); printf("%i\n",adc_val); delay(1000); } } void adc_init(void) { PINSEL1 = 0x01000000; // P0.28 - AD0.1 PCONP |= 0x00001000; AD0CR &= 0x00000000; AD0CR |= 0x00201302; // with clock = PCLK/(7+1) = 30Mhz/8 = 3.75Mhz AD0INTEN &= 0x00000000; } void adc_read(void) { AD0CR |= 0x01000000; // Start AD conversion NOW on AD0.1 (P0.28) delay(100); do { val = AD0DR1; // Get value } while ((val & 0x80000000) == 0); // until bit 31 is high (DONE) val = (val>>6); adc_val = val & 0x3FF; // Extract AD result } void delay(int delay_value) { int out_delay=0,in_delay=0; for(out_delay=0 ; out_delay < delay_value ; out_delay++) { for(in_delay=0 ; in_delay <= 1000 ; in_delay++); } }