ARM Technical Support Knowledge Articles

A/D EXAMPLES FOR THE ADUC812

Answer


Information in this article applies to:


QUESTION

Are there any examples for the Analog Devices ADuC812 A/D converter?

ANSWER

Yes. The following example code programs and reads the A/D for that device.

#include 
#include 

void main (void)
{
unsigned char chan_2_convert;

/*-----------------------------------------------
Configure the serial port to run at 300 Baud.
Yeah, this is really slow!
-----------------------------------------------*/
SCON  = 0x50;
TMOD |= 0x20;
TH1   = 0xA0;
TR1   = 1;
TI    = 1;

/*-----------------------------------------------
Configure the A/D to sequentially convert each
input channel.
-----------------------------------------------*/
ADCCON1 = 0x7C;     // 0111 1100

while (1)
  {
  unsigned int conv_val;
  unsigned char channel;

/*-----------------------------------------------
Start a conversion and wait for it to complete.
-----------------------------------------------*/
  chan_2_convert = (chan_2_convert + 1) % 8;
  ADCCON2 = (ADCCON2 & 0xF0) | chan_2_convert;
  SCONV = 1;
  while (ADCCON3 & 0x80);

/*-----------------------------------------------
Read A/D data and print it out.
-----------------------------------------------*/
  channel  = ADCDATAH >> 4;
  conv_val = ADCDATAL | ((ADCDATAH & 0x0F) << 8);

  printf ("ADC Channel %bu = 0x%4.4X\r\n", channel, conv_val);
  }
}

MORE INFORMATION

You may download this complete ADuC812 example for uVision2 from the Keil web site.

SEE ALSO

Article last edited on: 2010-02-04 04:55:18

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential