Results 1 to 7 of 7

Thread: Multi channel ADC in ARM

  1. #1

    Default Multi channel ADC in ARM

    Hi, could some one please explain me how to use multi channel ADC in ARM?
    I am using LPC2138 board.

  2. #2

    Default ADC LPC2138

    This code works for me. You might like to read the user manual in detail.Setting up the peripherals are well explained there :

    Code:
    /**************************************************************************************
    	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);
    	
    }

  3. #3

    Default

    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.

  4. #4

    Default

    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?

  5. #5
    Senior Member Android
    Join Date
    Jan 2008
    Location
    KGP
    Posts
    104

    Default

    see user manual for LPC3138, page 239
    For every minute that is spent in organizing, one hour is earned !

    http://elecrom.wordpress.com/

  6. #6

    Default

    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.

  7. #7
    Junior Member Newbie
    Join Date
    Jun 2014
    Location
    Chennai
    Posts
    1

    Cool Well code

    Quote Originally Posted by emb_sys_dev View Post
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •