| ??? 11/15/09 21:32 Read: times |
#170852 - ADUC816 |
Hello! I am a student trying to use the Analog Devices ADU816 microcontroller. I'm trying to simply turn on the primary ADC in order to read in a voltage between 0 and 2.5 Volts. However, I am getting an error with ADC0CON. The compiler gives an error when I use ADC0M. It seems to work if I use the auxiliary ADC which uses ADC1L and ADC1H. That is the only problem I seem to be having with compiling the code (Using Keil compiler). Any insight into this would be greatly appreciated!
Here is my code: #include <ADUC816.H>
#include <stdio.h>
void main (void)
{
/*-----------------------------------------------
Configure the serial port
-----------------------------------------------*/
SCON = 0x50;
TMOD |= 0x20;
TH1 = 0xFA;
TR1 = 1;
TI = 1;
PCON |= 0x80;
/*-----------------------------------------------
Configure the A/D to sequentially convert each
input channel.
-----------------------------------------------*/
ADC0CON = 0x17;
SF = 0x0D;
while (1)
{
unsigned int conv_val;
/*-----------------------------------------------
Start a conversion and wait for it to complete.
-----------------------------------------------*/
ADCMODE |= 0x12;
while (RDY1 != 1);
RDY0 = 0; /*Ready bit for PRIMARY ADC
/*-----------------------------------------------
Read A/D data and print it out.
-----------------------------------------------*/
conv_val = ADC0M | ((ADC0H) << 8);
printf ("Aux ADC Channel 3 = 0x%4.4Xrn", conv_val);
}
}
|
| Topic | Author | Date |
| ADUC816 | 01/01/70 00:00 | |
| what error? which compiler? | 01/01/70 00:00 | |
| Not seeing output values. | 01/01/70 00:00 | |
| while (RDY1 != 1); | 01/01/70 00:00 | |
| ADCMODE change | 01/01/70 00:00 | |
| Success! | 01/01/70 00:00 | |
Well done | 01/01/70 00:00 |



