This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

No output at ADC of LPC2148

I Good evening Everyone.

I am beginner for Programming of LPC2148.

I am making a project on transmitting temperature and location on my mobile by Bluetooth HC-05.

So I am using  UART0 and ADC 0.6 such that Received data from GPS (NEO -6M) and ADC (LM35) will be transmitted to HC-05 

Below is the program, I have written I am getting GPS data but no output from ADC0.6. 

#include<lpc214x.h>
void pll0(void);
void uart0(void);
char adc0_lm35(void);
char gps_data(void);
void message(char *ch);
void tx(unsigned char a);
void delay(int b);

int main()
{
PINSEL0 = 0x00000305;
char gps;
char adc;
while(1)
{
pll0();
uart0();
gps = gps_data();
adc = adc0_lm35();
message(&gps);
message(&adc);
}
}

void pll0(void) //setting PLL0 to generate 60Mhz Peripheral clock for UART0,UART1 and ADC0;
{
PLL0CON = 0x01; //Enable PLL0
PLL0CFG = 0x24; //Configure PLL0 as P=2 and M=5 to generate PCLK = 60Mhz
PLL0FEED = 0xAA; //PLLFEED sequence
PLL0FEED = 0x55; //PLLFEED sequence
if((PLL1STAT&0x0400)==0); //wait till PLL locks at 60Mhz
PLL0CON = 0x03; //Enable and connect PLL
PLL0FEED = 0xAA; //PLLFEED sequence
PLL0FEED = 0x55; //PLLFEED sequence
VPBDIV = 0x01; //VPB bus clock is same as processor clock
}

void uart0(void) //setting baud rate to 9600 for gps in UART0
{
U0LCR = 0x83; //world length 8bit, single stop bit, disable parity generator, odd parity, disable break transmittion, Enable Divisor latches
U0DLL = 110; // load U0DLL = 110
U0DLM = 1; // load U0DLM = 1
U0FDR = (15<<4) | 1; //MULVAL = 15; Enable Divisor latches
U0LCR &= 0x0F; // Disable Divisor latches
}

char gps_data(void)
{
while((U0LSR & 0x01) == 0);
return (U0RBR);
}

void message(char *ch)
{
while(*ch!='\0')
{
tx(*ch);
ch++;
}
}

void tx(unsigned char a)
{
while((U0LSR & 0x20) == 0);
U0THR = a;
}

void delay(int b)
{
T0CTCR = 0x00;
T0PR = 12000000;
T0TCR = 0x02;
T0TCR = 0x01;
while(T0TC<b);
T0TCR = 0x00;
}

char adc0_lm35(void)
{
char adc;
while(1)
{
AD0CR=0x01201440;
while(!(AD0GDR&0x80000000)); // Wait for the done bit to finish (using the general register)
adc = ((AD0GDR>>6)&0x3FF);
return (adc);
}
}

0