Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

A/D converter resolution problems

2004-12-10 by shaneprobinson2000

Hello all, I am having some difficulty getting 10 bit resolution out 
of the A/d converter on the LPC2129.  I have an opamp directly 
coupled to the input of the A/D converter, I am running the A/d 
clock at less the 4.5 MHZ, and I am only getting 7 or 8 bits.

The code I am using is as follows:

unsigned long AtoD(void)
{   
    unsigned long  result;
    
    REG(ATOD_ADCR)=0x00000802;                          //turn the 
a/d off with the channel selected
    REG(ATOD_ADCR)=0x00200802;                          //turn the 
a/d on with the channel selected
    REG(ATOD_ADCR)=0x01200802;                          //do the a/d
    while((!REG(ATOD_ADDR))&BIT31);                     //wait for it
    green_result=(REG(ATOD_ADDR) & 0xFFFF);             //read the 
result but ignore
    REG(ATOD_ADCR)=0x01200802;                          //do the 
conversion again
    while((!REG(ATOD_ADDR))&BIT31);                     //wait for it
    result=(REG(ATOD_ADDR) & 0xFFFF);             //read the result 
(result in bits 7-16)
    result>>=6;                                   //shift result 
over so result is in lower bits
    
    return(result);               
}

I have found that if I don't cycle the power with the correct 
channel selected it doesn't change channels.  This is covered 
somewhat in the errata.  Please help!

Shane.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.