??? 11/16/09 17:32 Read: times |
#170875 - ADCMODE change Responding to: ???'s previous message |
You're right, that was a problem. Also, I changed ADCMODE to ADCMODE |= 0x22;
Now whether I input 0 Volts or 5 Volts, I get the output 0x8000. Does it sound like I may have selected the wrong channels for the primary ADC? I will repost the 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 |= 0x22; while (RDY0 != 1); RDY1 = 0; /*Ready bit for PRIMARY ADC /*----------------------------------------------- 1 Read A/D data and print it out. -----------------------------------------------*/ conv_val = ADC0M | ((ADC0H) << 8); printf ("Primary 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 |