Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ADC code for lpc 2148

Status
Not open for further replies.

vasureddy37

Newbie level 1
Joined
Jul 6, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
hi friends ,
I am new to ARM ..I have developed a code for ADC , i am giving external DC voltage to ADC which it should convert into digital data and show in the system...



#include<LPC214x.h>
#include<stdio.h>

#include<string.h>
#include"LPCLCD.h"
#include"LPCCOM.h"


char buff[20];
unsigned int ADC1_Read(void);
unsigned int adc_out=0,loc=0;
char D_Buf[4];
int main()
{
VPBDIV=0x01;
Seril_Init(0,38400,9600);
Com0_Int_Enable();

lcd_init();
message(0x80,"Sampling");
PINSEL1|=0x15480000;
DACR=1<<16;

while(1)
{

adc_out=ADC1_Read();
sprintf(buff,"%d,",adc_out);

}
}
unsigned int ADC1_Read(void)
{
unsigned int i=0;
AD0CR = 0x00240602 ; // Init ADC (Pclk = 12MHz) and select channel 1,8bit digital data
AD0CR |= 0x01000000; // Start A/D Conversion
do
{
i = AD0DR1; // Read A/D Data Register
} while ((i & 0x80000000) == 0); // Wait for end of A/D Conversion
delay(9);
return (i >> 6) & 0x00FF; // bit 6:15 is 8 bit AD value

}


the code is executing ,but i am not able to receive the data in the system .......plz help me its urgent
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top