arunbharathi.arasu
Full Member level 2
- Joined
- Feb 28, 2013
- Messages
- 134
- Helped
- 7
- Reputation
- 14
- Reaction score
- 6
- Trophy points
- 1,298
- Location
- Chennai, Tamil Nadu, India
- Activity points
- 2,151
hai Friends,
I have problem in LPC2148 ADC code.
I have written code in keil compiler,the ADC output data will displaly in to UART
Here i post ADC initialization code and ADC read code.
please check it out and help me...
I have problem in LPC2148 ADC code.
I have written code in keil compiler,the ADC output data will displaly in to UART
Here i post ADC initialization code and ADC read code.
please check it out and help me...
Code:
#include<lpc214x.h>
void adc0_init(void)
{
// Enable ADC0
AD0CR &= 0x00000000; // Clear All Bit Control
AD0CR |= 0x00000400; // ADC Clock = VPB(PCLK) / 8
AD0CR &= 0xFFFEFFFF; // Busrt = 0 - Conversions are software controlled and reguire 11 clocks
AD0CR &= 0xFFF1FFFF; // CLKS = 000 - 10Bit : 11 Cycle Clock Conversion
AD0CR |= 0x00200000; // PDN = 1 - Active ADC Module
}
unsigned int adc0_channel_1(void)
{
unsigned int val;
// Initial AD0.1 (P0.28) By Set PINSEL1[25:24=01]
// xxxx xx01 xxxx xxxx xxxx xxxx xxxx xxxx
PINSEL1 |= 0x01000000; // channel 1 in adc0
AD0CR &= 0xffffff00;
AD0CR |= 0x00000002; // Select ADC = AD0.1
// START = 001 = Start Conversion Now
AD0CR |= 0x01000000;
// Wait ADC Conversion to Complete and Read A/D Data Register
//uart0_putch('6');
while(!(AD0GDR & 0X80000000));
// Shift ADC Result to Integer
val = (unsigned int)(AD0DR1 >> 6) & 0x000003FF;
AD0CR &= 0xF8FFFFFF; //STOP THE ADC
return (val);
}