This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to read channel 3 of ADC on LPC2119

Hi all,

I have a grasp of setting up the ADC on the LPC2119 (by Phillps NXP). However, when it comes to reading the different channels I seem to be a little lost.

Please could someone explain how you can request the data from a specific channel of the ADC? As reading the ADDR is self explanatory, but reading a specific channel is not mentioned in the datasheet or user manual.

Many thanks

  • I hope you don't get too surprised if I claim that the user manual for the processor is a good source of information.

    It does describe the ADCR register - A/D Control Register - that you must write to to perform an AD conversion.

    It does describe that bits 0 to 7 selects which analog input pins to read from. If doing a single conversion, you select a single bit. And then you can read the corresponding value in ADDR when the conversion is done.

    If you do a burst conversion, you can set multiple input bits in ADCR. You then need to read out the individual values from ADDR as they arrive, or the ADDR register will set the OVERUN bit.

    You can see in ADDR when the conversion is done - logically informed in the bit 31 (DONE).
    You can see which channel (input pin) that was converted, using bit 24..26 (CHN).
    And the result is available in bits 6..15.

    So no - I don't agree with you when you claim that "reading a specific channel is not mentioned in the datasheet or user manual".

    By the way - NXP ARM chips have all the programming information in the "user manual", while mechanical, electrical and timing information are in the "data sheet".

    I haven't checked if I have the latest user manual. It's from 2004-05-03, and the ADC covers page 238 to 241. Four pages that you should read at least three or four times since the information will make more sense when you have seen the full concept at least once or twice.

    The Hitex book linked above contains good information about how to set up interrupt handlers etc. And the examples installed with the Keil tools contains several examples for 21xx processors.

  • Through reading the user manual which I agree is a very good source of information on the majority of aspects, I have become familiar with how the A/D is set up and how it operates.

    However, I was given the task of reading three channels of the A/D when operating it in software mode. This caused confussion between the terminology of user manual and that given in the task, as the terminology of the user manual didnt make it clear that in programmable mode you had to start and stop each channel one at a time using the ADCR register in order to read from a specific channel.

    Thank you for your help, but I dont think I would of got a response unless I posted my previous rant.

  • Exactly - but I'm not expected to spend time looking at manuals for processors I don't use on business hours, am I?

    I normally answer when the question is related to processors I already know about. After all, I'm not any Keil employee. Just a user of Keil tools just like you.

  • I don't think that the manual is confusing.
    It states very clearly that you should only enable one channel in software mode.


    ADCR b7:0
    Selects which of the Ain3:0 (LPC2119/2129/2194) or Ain7:0 (LPC2292/2294) pins is (are) to
    be sampled and converted. Only bits 3:0 should be set to 1 in the 48 or 64 pin package. In
    software-controlled mode, only one of these bits should be 1.
    In hardware scan mode, any
    value containing 1 to 8 ones (1 to 4 ones in the 48 or 64 pin package) can be used. All zeroes
    is equivalent to 0x01.

    Alex

  • Note that this is a different user asking a slightly different question for a different processor with a different ADC, even if both chips are in the LPC21xx family.

  • What do you mean?

    The quote in my reply is from the LPC2119 user manual, that is exactly the mcu that the question refers to.

    Alex