----- Original Message -----
From: "R CHANTHAR"
To:
Sent: Sunday, March 16, 2008 12:47 PM
Subject: [lpc2000] Using ADC in LPC2129
> Hello friends,
>
> Im new to this ARM field and im doing a project of
> monitoring the temperature using LM35 and ARM7(part of my project).Can
> anyone tell me how to configure the 10 bit ADC in LPC2129 to convert the
> temperature or give me some example programs for using ADC.Also should I
> use software or hardware mode for ADC?
This is the code I use (polling the ADC):
// initialise ADC
PINSEL0 = PINSEL0 | 0x00003C00; // P0.5, P0.6 setup for AD0.7, AD1.0
inputs
// bits 11:10 13:12
// 11 11
PINSEL1 = 0x15000000; // P0.28, P0.29, P0.30 set for AD0.1, AD0.2, AD0.3
inputs
// bits 25:24 27:26 30:29
// 01 01 01
AD0CR = 0x00200604; // enable ADC, 11 clocks/10 bits, ADC clock = 4.286
MHz
AD1CR = 0x00208001;
//-------------------------- getAnalogueInput_AD0 function ---------------//
unsigned short int getAnalogueInput_AD0(unsigned char channel)
{
unsigned short int val;
//start conversion (for selected channel)
AD0CR = (AD0CR & 0xFFFFFF00) | (1 << channel) | (1 << 24);
//wait until done
while((AD0GDR & 0x80000000) == 0)
;
// get ADC data
val = ((AD0GDR & 0x0000FFC0)) >> 6;
return(val);
}
Leon Heller
Amateur radio call-sign G1HSM
Yaesu FT-817ND and FT-857D transceivers
Suzuki SV1000S motorcycle
l...@btinternet.com
http://webspace.webring.com/people/jl/leon_heller/