Yahoo Groups archive

Lpc2000

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

Thread

AD0 not working properly - help

AD0 not working properly - help

2006-03-03 by Sutton Mehaffey

I am trying to read a battery voltage (~12V) on AD0 channel 2.  I have
a breadboard circuit with a voltage divider that is working properly
that gives a reading between 1.8V and 2.3V more or less.  I am using a
variable power supply to generate these voltages.

When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all 10 bits
high) no matter what.  Can someone tell by the code below if I have a
setting wrong?  My PCLK is 12Mhz.


AD0CR |= 0x00200000;  // turn on AD0
AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
AD0CR |= 0x00000004;  // select channel AD0.2
AD0CR |= 0x01000000;  // start conversion now

while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in AD0STAT
result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result (0-2055)

DONE2 is set, and result is always CFF.

Sutton - dodge1955

Re: [lpc2000] AD0 not working properly - help

2006-03-03 by Richard Duits

You should start the AD conversion with a single write and not a series 
of read-modify-write operations.

Also make sure that none of the ADC capable pins stay below 3.3 Volt 
even if they are not used as ADC inputs (see errata for more info).

Make sure you configure the pin as ADC input with the pin configuration 
registers.

Regards,
Richard.




Sutton Mehaffey wrote:
Show quoted textHide quoted text
> Please help us to improve Yahoo! Groups. Take the survey now! 
> <http://v2.decipherinc.com/survey/yahoo/yah05014?list=18>
> I am trying to read a battery voltage (~12V) on AD0 channel 2.  I have
> a breadboard circuit with a voltage divider that is working properly
> that gives a reading between 1.8V and 2.3V more or less.  I am using a
> variable power supply to generate these voltages.
>
> When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all 10 bits
> high) no matter what.  Can someone tell by the code below if I have a
> setting wrong?  My PCLK is 12Mhz.
>
>
> AD0CR |= 0x00200000;  // turn on AD0
> AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
> AD0CR |= 0x00000004;  // select channel AD0.2
> AD0CR |= 0x01000000;  // start conversion now
>
> while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in AD0STAT
> result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result (0-2055)
>
> DONE2 is set, and result is always CFF.
>
> Sutton - dodge1955

Re: AD0 not working properly - help

2006-03-03 by Sutton Mehaffey

Richard,

I had these set up in an init file that I didn't include with the code.

Also, it didn't matter if I did the write to AD0CR all at once or
separate.  No change in the data.

I couldn't find anything in the errata sheet.  I printed out Errata
1.2 released on 2/27.  Where is the errata you were referring to?

Sutton


IODIR0 &= 0x8FFFFFFF;   // AD0 (P0.28, P0.29, P0.30) defined as inputs
PCONP |= 0x00001000;    // Enable AD0
PINSEL1 |= 0x15000000;  // AD0.1, AD0.2, AD0.3 all defined

AD0CR = 0x01200404;

// AD0CR |= 0x00200000;  // turn on AD0
// AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
// AD0CR |= 0x00000004;  // select channel AD0.2
// AD0CR |= 0x01000000;  // start conversion now

while ((AD0STAT & 0x00000004) == 0);  // DONE2 status bit in AD0STAT
result = (AD0DR2 & 0x0000FFC0) >> 6;  // bits 6-15 are result (0-2055)


 

--- In lpc2000@yahoogroups.com, Richard Duits <yahoo@...> wrote:
>
> You should start the AD conversion with a single write and not a series 
> of read-modify-write operations.
> 
> Also make sure that none of the ADC capable pins stay below 3.3 Volt 
> even if they are not used as ADC inputs (see errata for more info).
> 
> Make sure you configure the pin as ADC input with the pin configuration 
> registers.
> 
> Regards,
> Richard.
> 
> 
> 
> 
> Sutton Mehaffey wrote:
> > Please help us to improve Yahoo! Groups. Take the survey now! 
> > <http://v2.decipherinc.com/survey/yahoo/yah05014?list=18>
> > I am trying to read a battery voltage (~12V) on AD0 channel 2.  I have
> > a breadboard circuit with a voltage divider that is working properly
> > that gives a reading between 1.8V and 2.3V more or less.  I am using a
> > variable power supply to generate these voltages.
> >
> > When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all 10 bits
> > high) no matter what.  Can someone tell by the code below if I have a
> > setting wrong?  My PCLK is 12Mhz.
> >
> >
> > AD0CR |= 0x00200000;  // turn on AD0
> > AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
> > AD0CR |= 0x00000004;  // select channel AD0.2
> > AD0CR |= 0x01000000;  // start conversion now
> >
> > while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in AD0STAT
> > result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result
(0-2055)
Show quoted textHide quoted text
> >
> > DONE2 is set, and result is always CFF.
> >
> > Sutton - dodge1955
>

Re: [lpc2000] Re: AD0 not working properly - help

2006-03-03 by Richard Duits

You did not say which part you are using. The issues with the ADC pins 
not being fully 5 volt tolerant may be solved in the newer parts 
(LPC214x, etc).

The others items were things I would check or do diffirently, I had no 
idea if they are the cause of your problem. Are you sure the conversion 
starts? You can add a counter to the wait loop to see if it waits a few 
cycles. If it doesn't, you did not start the AD conversion and you need 
to check the value you write to the ADCR register.

Richard.


Sutton Mehaffey wrote:
Show quoted textHide quoted text
> Richard,
>
> I had these set up in an init file that I didn't include with the code.
>
> Also, it didn't matter if I did the write to AD0CR all at once or
> separate.  No change in the data.
>
> I couldn't find anything in the errata sheet.  I printed out Errata
> 1.2 released on 2/27.  Where is the errata you were referring to?
>
> Sutton
>
>
> IODIR0 &= 0x8FFFFFFF;   // AD0 (P0.28, P0.29, P0.30) defined as inputs
> PCONP |= 0x00001000;    // Enable AD0
> PINSEL1 |= 0x15000000;  // AD0.1, AD0.2, AD0.3 all defined
>
> AD0CR = 0x01200404;
>
> // AD0CR |= 0x00200000;  // turn on AD0
> // AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
> // AD0CR |= 0x00000004;  // select channel AD0.2
> // AD0CR |= 0x01000000;  // start conversion now
>
> while ((AD0STAT & 0x00000004) == 0);  // DONE2 status bit in AD0STAT
> result = (AD0DR2 & 0x0000FFC0) >> 6;  // bits 6-15 are result (0-2055)
>
>
>
>
> --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@...> wrote:
> >
> > You should start the AD conversion with a single write and not a series
> > of read-modify-write operations.
> >
> > Also make sure that none of the ADC capable pins stay below 3.3 Volt
> > even if they are not used as ADC inputs (see errata for more info).
> >
> > Make sure you configure the pin as ADC input with the pin configuration
> > registers.
> >
> > Regards,
> > Richard.
> >
> >
> >
> >
> > Sutton Mehaffey wrote:
> > > Please help us to improve Yahoo! Groups. Take the survey now!
> > > <http://v2.decipherinc.com/survey/yahoo/yah05014?list=18>
> > > I am trying to read a battery voltage (~12V) on AD0 channel 2.  I have
> > > a breadboard circuit with a voltage divider that is working properly
> > > that gives a reading between 1.8V and 2.3V more or less.  I am using a
> > > variable power supply to generate these voltages.
> > >
> > > When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all 10 bits
> > > high) no matter what.  Can someone tell by the code below if I have a
> > > setting wrong?  My PCLK is 12Mhz.
> > >
> > >
> > > AD0CR |= 0x00200000;  // turn on AD0
> > > AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
> > > AD0CR |= 0x00000004;  // select channel AD0.2
> > > AD0CR |= 0x01000000;  // start conversion now
> > >
> > > while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in AD0STAT
> > > result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result
> (0-2055)
> > >
> > > DONE2 is set, and result is always CFF.
> > >
> > > Sutton - dodge1955
> >
>
>

Re: AD0 not working properly - help

2006-03-03 by Sutton Mehaffey

Sorry.  Using LPC2148 on an Embedded Artists Quickstart and Prototype
Board.  Prototype board is nice to have.  Conversion starts because I
get the DONE bit set after a few cycles.  But value read is always all
10 bits high.  I've tried all 3 AD0 (0 doesn't exist) channels (1
channel was determined bad - it has a short to ground).  Haven't
figured out why yet on the all high readings.

Sutton



--- In lpc2000@yahoogroups.com, Richard Duits <yahoo@...> wrote:
>
> You did not say which part you are using. The issues with the ADC pins 
> not being fully 5 volt tolerant may be solved in the newer parts 
> (LPC214x, etc).
> 
> The others items were things I would check or do diffirently, I had no 
> idea if they are the cause of your problem. Are you sure the conversion 
> starts? You can add a counter to the wait loop to see if it waits a few 
> cycles. If it doesn't, you did not start the AD conversion and you need 
> to check the value you write to the ADCR register.
> 
> Richard.
> 
> 
> Sutton Mehaffey wrote:
> > Richard,
> >
> > I had these set up in an init file that I didn't include with the
code.
> >
> > Also, it didn't matter if I did the write to AD0CR all at once or
> > separate.  No change in the data.
> >
> > I couldn't find anything in the errata sheet.  I printed out Errata
> > 1.2 released on 2/27.  Where is the errata you were referring to?
> >
> > Sutton
> >
> >
> > IODIR0 &= 0x8FFFFFFF;   // AD0 (P0.28, P0.29, P0.30) defined as inputs
> > PCONP |= 0x00001000;    // Enable AD0
> > PINSEL1 |= 0x15000000;  // AD0.1, AD0.2, AD0.3 all defined
> >
> > AD0CR = 0x01200404;
> >
> > // AD0CR |= 0x00200000;  // turn on AD0
> > // AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz
ADC clk)
> > // AD0CR |= 0x00000004;  // select channel AD0.2
> > // AD0CR |= 0x01000000;  // start conversion now
> >
> > while ((AD0STAT & 0x00000004) == 0);  // DONE2 status bit in AD0STAT
> > result = (AD0DR2 & 0x0000FFC0) >> 6;  // bits 6-15 are result (0-2055)
> >
> >
> >
> >
> > --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@> wrote:
> > >
> > > You should start the AD conversion with a single write and not a
series
> > > of read-modify-write operations.
> > >
> > > Also make sure that none of the ADC capable pins stay below 3.3 Volt
> > > even if they are not used as ADC inputs (see errata for more info).
> > >
> > > Make sure you configure the pin as ADC input with the pin
configuration
> > > registers.
> > >
> > > Regards,
> > > Richard.
> > >
> > >
> > >
> > >
> > > Sutton Mehaffey wrote:
> > > > Please help us to improve Yahoo! Groups. Take the survey now!
> > > > <http://v2.decipherinc.com/survey/yahoo/yah05014?list=18>
> > > > I am trying to read a battery voltage (~12V) on AD0 channel 2.
 I have
> > > > a breadboard circuit with a voltage divider that is working
properly
> > > > that gives a reading between 1.8V and 2.3V more or less.  I am
using a
> > > > variable power supply to generate these voltages.
> > > >
> > > > When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all
10 bits
> > > > high) no matter what.  Can someone tell by the code below if I
have a
> > > > setting wrong?  My PCLK is 12Mhz.
> > > >
> > > >
> > > > AD0CR |= 0x00200000;  // turn on AD0
> > > > AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz
ADC clk)
> > > > AD0CR |= 0x00000004;  // select channel AD0.2
> > > > AD0CR |= 0x01000000;  // start conversion now
> > > >
> > > > while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in
AD0STAT
Show quoted textHide quoted text
> > > > result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result
> > (0-2055)
> > > >
> > > > DONE2 is set, and result is always CFF.
> > > >
> > > > Sutton - dodge1955
> > >
> >
> >
>

Re: [lpc2000] Re: AD0 not working properly - help

2006-03-07 by K B Shah-lascaux

Is it not suppose to be IO0DIR  &= 0x8FFFFFFF;...???  (You have IODIR0 )   ???
Show quoted textHide quoted text
  ----- Original Message ----- 
  From: Sutton Mehaffey 
  To: lpc2000@yahoogroups.com 
  Sent: Friday, March 03, 2006 4:56 PM
  Subject: [lpc2000] Re: AD0 not working properly - help


  Richard,

  I had these set up in an init file that I didn't include with the code.

  Also, it didn't matter if I did the write to AD0CR all at once or
  separate.  No change in the data.

  I couldn't find anything in the errata sheet.  I printed out Errata
  1.2 released on 2/27.  Where is the errata you were referring to?

  Sutton


  IODIR0 &= 0x8FFFFFFF;   // AD0 (P0.28, P0.29, P0.30) defined as inputs
  PCONP |= 0x00001000;    // Enable AD0
  PINSEL1 |= 0x15000000;  // AD0.1, AD0.2, AD0.3 all defined

  AD0CR = 0x01200404;

  // AD0CR |= 0x00200000;  // turn on AD0
  // AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
  // AD0CR |= 0x00000004;  // select channel AD0.2
  // AD0CR |= 0x01000000;  // start conversion now

  while ((AD0STAT & 0x00000004) == 0);  // DONE2 status bit in AD0STAT
  result = (AD0DR2 & 0x0000FFC0) >> 6;  // bits 6-15 are result (0-2055)




  --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@...> wrote:
  >
  > You should start the AD conversion with a single write and not a series 
  > of read-modify-write operations.
  > 
  > Also make sure that none of the ADC capable pins stay below 3.3 Volt 
  > even if they are not used as ADC inputs (see errata for more info).
  > 
  > Make sure you configure the pin as ADC input with the pin configuration 
  > registers.
  > 
  > Regards,
  > Richard.
  > 
  > 
  > 
  > 
  > Sutton Mehaffey wrote:
  > > Please help us to improve Yahoo! Groups. Take the survey now! 
  > > <http://v2.decipherinc.com/survey/yahoo/yah05014?list=18>
  > > I am trying to read a battery voltage (~12V) on AD0 channel 2.  I have
  > > a breadboard circuit with a voltage divider that is working properly
  > > that gives a reading between 1.8V and 2.3V more or less.  I am using a
  > > variable power supply to generate these voltages.
  > >
  > > When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all 10 bits
  > > high) no matter what.  Can someone tell by the code below if I have a
  > > setting wrong?  My PCLK is 12Mhz.
  > >
  > >
  > > AD0CR |= 0x00200000;  // turn on AD0
  > > AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz ADC clk)
  > > AD0CR |= 0x00000004;  // select channel AD0.2
  > > AD0CR |= 0x01000000;  // start conversion now
  > >
  > > while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in AD0STAT
  > > result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result
  (0-2055)
  > >
  > > DONE2 is set, and result is always CFF.
  > >
  > > Sutton - dodge1955
  >







  SPONSORED LINKS Microcontrollers  Microprocessor  Intel microprocessors  
        Pic microcontrollers  


------------------------------------------------------------------------------
  YAHOO! GROUPS LINKS 

    a..  Visit your group "lpc2000" on the web.
      
    b..  To unsubscribe from this group, send an email to:
     lpc2000-unsubscribe@yahoogroups.com
      
    c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


------------------------------------------------------------------------------




------------------------------------------------------------------------------


  No virus found in this incoming message.
  Checked by AVG Free Edition.
  Version: 7.1.375 / Virus Database: 268.1.1/273 - Release Date: 02/03/2006


[Non-text portions of this message have been removed]

Re: AD0 not working properly - help

2006-03-07 by Sutton Mehaffey

It is IODIR0 in the Keil compiler.  I think it is IO0DIR in IAR and
others.

Sutton



--- In lpc2000@yahoogroups.com, "K B Shah-lascaux" <kbshah@...> wrote:
>
> Is it not suppose to be IO0DIR  &= 0x8FFFFFFF;...???  (You have
IODIR0 )   ???
>   ----- Original Message ----- 
>   From: Sutton Mehaffey 
>   To: lpc2000@yahoogroups.com 
>   Sent: Friday, March 03, 2006 4:56 PM
>   Subject: [lpc2000] Re: AD0 not working properly - help
> 
> 
>   Richard,
> 
>   I had these set up in an init file that I didn't include with the
code.
> 
>   Also, it didn't matter if I did the write to AD0CR all at once or
>   separate.  No change in the data.
> 
>   I couldn't find anything in the errata sheet.  I printed out Errata
>   1.2 released on 2/27.  Where is the errata you were referring to?
> 
>   Sutton
> 
> 
>   IODIR0 &= 0x8FFFFFFF;   // AD0 (P0.28, P0.29, P0.30) defined as inputs
>   PCONP |= 0x00001000;    // Enable AD0
>   PINSEL1 |= 0x15000000;  // AD0.1, AD0.2, AD0.3 all defined
> 
>   AD0CR = 0x01200404;
> 
>   // AD0CR |= 0x00200000;  // turn on AD0
>   // AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz
ADC clk)
>   // AD0CR |= 0x00000004;  // select channel AD0.2
>   // AD0CR |= 0x01000000;  // start conversion now
> 
>   while ((AD0STAT & 0x00000004) == 0);  // DONE2 status bit in AD0STAT
>   result = (AD0DR2 & 0x0000FFC0) >> 6;  // bits 6-15 are result (0-2055)
> 
> 
> 
> 
>   --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@> wrote:
>   >
>   > You should start the AD conversion with a single write and not a
series 
>   > of read-modify-write operations.
>   > 
>   > Also make sure that none of the ADC capable pins stay below 3.3
Volt 
>   > even if they are not used as ADC inputs (see errata for more info).
>   > 
>   > Make sure you configure the pin as ADC input with the pin
configuration 
>   > registers.
>   > 
>   > Regards,
>   > Richard.
>   > 
>   > 
>   > 
>   > 
>   > Sutton Mehaffey wrote:
>   > > Please help us to improve Yahoo! Groups. Take the survey now! 
>   > > <http://v2.decipherinc.com/survey/yahoo/yah05014?list=18>
>   > > I am trying to read a battery voltage (~12V) on AD0 channel 2.
 I have
>   > > a breadboard circuit with a voltage divider that is working
properly
>   > > that gives a reading between 1.8V and 2.3V more or less.  I am
using a
>   > > variable power supply to generate these voltages.
>   > >
>   > > When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all
10 bits
>   > > high) no matter what.  Can someone tell by the code below if I
have a
>   > > setting wrong?  My PCLK is 12Mhz.
>   > >
>   > >
>   > > AD0CR |= 0x00200000;  // turn on AD0
>   > > AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz
ADC clk)
>   > > AD0CR |= 0x00000004;  // select channel AD0.2
>   > > AD0CR |= 0x01000000;  // start conversion now
>   > >
>   > > while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in
AD0STAT
>   > > result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result
>   (0-2055)
>   > >
>   > > DONE2 is set, and result is always CFF.
>   > >
>   > > Sutton - dodge1955
>   >
> 
> 
> 
> 
> 
> 
> 
>   SPONSORED LINKS Microcontrollers  Microprocessor  Intel
microprocessors  
>         Pic microcontrollers  
> 
> 
>
------------------------------------------------------------------------------
>   YAHOO! GROUPS LINKS 
> 
>     a..  Visit your group "lpc2000" on the web.
>       
>     b..  To unsubscribe from this group, send an email to:
>      lpc2000-unsubscribe@yahoogroups.com
>       
>     c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service. 
> 
> 
>
------------------------------------------------------------------------------
> 
> 
> 
> 
>
------------------------------------------------------------------------------
> 
> 
>   No virus found in this incoming message.
>   Checked by AVG Free Edition.
>   Version: 7.1.375 / Virus Database: 268.1.1/273 - Release Date:
02/03/2006
Show quoted textHide quoted text
> 
> 
> [Non-text portions of this message have been removed]
>

Re: [lpc2000] Re: AD0 not working properly - help

2006-03-07 by 3gpabko

I think that you miss some details in your question.
 Can you verify  that at the moment of starting of the AD conversion the AINx pins are  configured as analog inputs. If you write to the PINSEL register at the  beginning of the program and after that you have another write to the  same PINSEL register which changes the configuration...
 Sure you  have to write to AD0CR in a separate write for setting the START bit.  First you can write to the register a configuration word and then with  a separate write to set the START bit. Be careful when  read-modify-write the AD0CR. If you have START bit already set it will  accidentally start a conversion. Then when you attempt to start the  conversion in the next line you may have the DONE bit set. Read the  manual and errata for details. In this case ensure that your  configuration word for AD0CR clears the START bitfield.
 Can you  verify that your hardware is setup properly. How you source the input  voltage to the AIN0 pin? Are the voltages on the other analog inputs  below 3.3V?
  

Sutton Mehaffey <sutton@...> wrote:          It is IODIR0 in the Keil compiler.  I think it is IO0DIR in IAR and
  others.
  
  Sutton
  
  
  
  --- In lpc2000@yahoogroups.com, "K B Shah-lascaux" <kbshah@...> wrote:
  >
  > Is it not suppose to be IO0DIR  &= 0x8FFFFFFF;...???  (You have
  IODIR0 )   ???
  >   ----- Original Message ----- 
  >   From: Sutton Mehaffey 
  >   To: lpc2000@yahoogroups.com 
  >   Sent: Friday, March 03, 2006 4:56 PM
  >   Subject: [lpc2000] Re: AD0 not working properly - help
  > 
  > 
  >   Richard,
  > 
  >   I had these set up in an init file that I didn't include with the
  code.
  > 
  >   Also, it didn't matter if I did the write to AD0CR all at once or
  >   separate.  No change in the data.
  > 
  >   I couldn't find anything in the errata sheet.  I printed out Errata
  >   1.2 released on 2/27.  Where is the errata you were referring to?
  > 
  >   Sutton
  > 
  > 
  >   IODIR0 &= 0x8FFFFFFF;   // AD0 (P0.28, P0.29, P0.30) defined as inputs
  >   PCONP |= 0x00001000;    // Enable AD0
  >   PINSEL1 |= 0x15000000;  // AD0.1, AD0.2, AD0.3 all defined
  > 
  >   AD0CR = 0x01200404;
  > 
  >   // AD0CR |= 0x00200000;  // turn on AD0
  >   // AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz
  ADC clk)
  >   // AD0CR |= 0x00000004;  // select channel AD0.2
  >   // AD0CR |= 0x01000000;  // start conversion now
  > 
  >   while ((AD0STAT & 0x00000004) == 0);  // DONE2 status bit in AD0STAT
  >   result = (AD0DR2 & 0x0000FFC0) >> 6;  // bits 6-15 are result (0-2055)
  > 
  > 
  > 
  > 
  >   --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@> wrote:
  >   >
  >   > You should start the AD conversion with a single write and not a
  series 
  >   > of read-modify-write operations.
  >   > 
  >   > Also make sure that none of the ADC capable pins stay below 3.3
  Volt 
  >   > even if they are not used as ADC inputs (see errata for more info).
  >   > 
  >   > Make sure you configure the pin as ADC input with the pin
  configuration 
  >   > registers.
  >   > 
  >   > Regards,
  >   > Richard.
  >   > 
  >   > 
  >   > 
  >   > 
  >   > Sutton Mehaffey wrote:
  >   > > Please help us to improve Yahoo! Groups. Take the survey now! 
  >   > > <http://v2.decipherinc.com/survey/yahoo/yah05014?list=18>
  >   > > I am trying to read a battery voltage (~12V) on AD0 channel 2.
   I have
  >   > > a breadboard circuit with a voltage divider that is working
  properly
  >   > > that gives a reading between 1.8V and 2.3V more or less.  I am
  using a
  >   > > variable power supply to generate these voltages.
  >   > >
  >   > > When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all
  10 bits
  >   > > high) no matter what.  Can someone tell by the code below if I
  have a
  >   > > setting wrong?  My PCLK is 12Mhz.
  >   > >
  >   > >
  >   > > AD0CR |= 0x00200000;  // turn on AD0
  >   > > AD0CR |= 0x00000400;  // divide 12Mhz clock by 3 (max 4.5Mhz
  ADC clk)
  >   > > AD0CR |= 0x00000004;  // select channel AD0.2
  >   > > AD0CR |= 0x01000000;  // start conversion now
  >   > >
  >   > > while ((AD0STAT & 0x00000004) == 0);   // DONE2 status bit in
  AD0STAT
  >   > > result = (AD0DR2 & 0x0000FFC0) >> 6;   // bits 6-15 are result
  >   (0-2055)
  >   > >
  >   > > DONE2 is set, and result is always CFF.
  >   > >
  >   > > Sutton - dodge1955
  >   >
  > 
  > 
  > 
  > 
  > 
  > 
  > 
  >   SPONSORED LINKS Microcontrollers  Microprocessor  Intel
  microprocessors  
  >         Pic microcontrollers  
  > 
  > 
  >
  ------------------------------------------------------------------------------
  >   YAHOO! GROUPS LINKS 
  > 
  >     a..  Visit your group "lpc2000" on the web.
  >       
  >     b..  To unsubscribe from this group, send an email to:
  >      lpc2000-unsubscribe@yahoogroups.com
  >       
  >     c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
  Service. 
  > 
  > 
  >
  ------------------------------------------------------------------------------
  > 
  > 
  > 
  > 
  >
  ------------------------------------------------------------------------------
  > 
  > 
  >   No virus found in this incoming message.
  >   Checked by AVG Free Edition.
  >   Version: 7.1.375 / Virus Database: 268.1.1/273 - Release Date:
  02/03/2006
  > 
  > 
  > [Non-text portions of this message have been removed]
  >
  
  
  
  
                    

          SPONSORED LINKS    
                                                        Microcontrollers                                          Microprocessor                                          Intel microprocessors                                                                          Pic microcontrollers                                                             
        
---------------------------------
    YAHOO! GROUPS LINKS  
  
      
    Visit your group "lpc2000" on the web.
     
    To unsubscribe from this group, send an email to:
 lpc2000-unsubscribe@yahoogroups.com
     
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.  
  
      
---------------------------------
  
  
          

		
---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 

[Non-text portions of this message have been removed]

Re: [lpc2000] AD0 not working properly - help

2006-03-30 by clemens fischer

> Sutton Mehaffey:

> When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all 10 bits
> high) no matter what.  Can someone tell by the code below if I have a
> setting wrong?  My PCLK is 12Mhz.

what about your Vref?

  clemens

Re: [lpc2000] AD0 not working properly - help

2006-03-30 by Sten

clemens fischer wrote:
>>Sutton Mehaffey:
> 
> 
>>When I connect the 1.8-2.3V to P0.29 (AD0.2), I read CFF (all 10 bits
>>high) no matter what.  Can someone tell by the code below if I have a
>>setting wrong?  My PCLK is 12Mhz.
> 
> 
> what about your Vref?
> 
>   clemens
> 

There're some nasty issues in the errata sheet concering AD!

  Sten

-- 
/************************************************
 Do you need a tiny and efficient real time
 operating system (RTOS) with a preemtive
 multitasking for LPC2000 or AT91SAM7?

   http://nanortos.net-attack.de/

 Or some open-source tools and code for LPC2000?

   http://www.net-attack.de/

************************************************/

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.