PDA

View Full Version : Multi channel ADC in ARM



anilmaddala
03-16-2009, 07:31 PM
Hi, could some one please explain me how to use multi channel ADC in ARM?
I am using LPC2138 board.

emb_sys_dev
03-17-2009, 12:03 PM
This code works for me. You might like to read the user manual in detail.Setting up the peripherals are well explained there :



/************************************************** ************************************
P0.27 ~ P0.30 are the bunched ADC port pins
PCLK = 27.6475MHz [config.h]
HEnce ADCLK = (27.6475 / 7 ) = 3.95 MHz
Channel+1 because channel 0 is 0x01
************************************************** *************************************/

#include "LPC21xx.h"
#include "config.h"
#include "ADC.h"
#include "uart.h"
#include <stdio.h>


uint32_t Init_Read_ADC(uint32_t Channel)
{
uint32_t ADC_Val;

// Set up PIN0.27,P0.28 as AI

PINSEL1 = (5UL<<22);
ADC_Val = AD0GDR;


AD0CR = 0x00200500 |(Channel+1); // see comment plate

AD0CR |= (1UL<<24); // start conversion


do
{
ADC_Val = AD0GDR; //Read A/D data register0
}
while ((ADC_Val & 0x80000000) == 0); //Wait for end of A/D

AD0CR &= ~0x01000000; // Stop A/D conversion

ADC_Val = ((ADC_Val >>6) & 0x000003FF); // extract result

return(ADC_Val);

}

anilmaddala
03-31-2009, 03:11 PM
Hi, I am Anil.
Regarding the code which ou have postted for multi channel ADC, Does it work for LPC2138?
and I couldnt find config.h, uart.h and ADC.h for Philips LPC2138.
Please help.

anilmaddala
04-02-2009, 02:10 PM
Hi,
Thanks for the reply. I looked into the manual could and understood most of the code. I am Using Keil compiler. Ididnt understand this part of the code:

AD0CR = 0x00200500 |(Channel+1); // see comment plate

Could you please explain it?
And what do you mean by bunched ports? Their inputs are not related to each other right?

elecrom
04-03-2009, 02:43 PM
see user manual for LPC3138, page 239

emb_sys_dev
04-06-2009, 04:51 PM
And what do you mean by bunched ports? Their inputs are not related to each other right?

Sorry about that misleading comment , it was a memory aid for me. My eval board has those pins brought out on a header for use as an ADC. No the inputs are not related to each other.

muniyan
06-29-2014, 01:11 PM
And what do you mean by bunched ports? Their inputs are not related to each other right?

Sorry about that misleading comment , it was a memory aid for me. My eval board has those pins brought out on a header for use as an ADC. No the inputs are not related to each other.

Yeah it is well working code and I can made few changes and it well working thanks man