Please consider the following codes:
//Code Sample 1
void func_val(void)
{
unsigned int val;
ADCSC1 = 0x00; // sets the required channel.
while(!ADCSC1_COCO); //check for conversion complete flag.
val= ADCRL;
}
//Code sample 2
void EvalProx()
{
unsigned int proxval;
ADCSC1 = 0x02; // sets the required channel.
while(!ADCSC1_COCO); //check for conversion complete flag.
proxval = ADCRL;
}
Now both the samples are snippets from a bigger code, which compiles and works.
My question is about the concept of Analog to Digital Converters in MCU.
ADCRL
and ADCRH
are the registers in which the converted values are stored.
ADCSC
is the status control register in which I have specified two different channels to be used.
Question: The ADCRL
/ADCRH
are same for the two different setting of the ADCSC
i.e. same for both the channels. So does the value of proxval
influence the value of val
when accessed? i.e. If func_val()
is executed and then
EvalProx()
, is the value of proxval
influenced by the val? (when both the values depend on ADCRH
and ADCRL
)
I hope I am clear. Before down voting this question, I request, please take some time to tell me why you have down voted, so I can improve my question.
Datasheet of the used MCU: MC9S08DZ60
Specific Page Numbers: Chapter 10 :- Page 181,182- for ADCRH
and ADCRL
.