Texas Instruments MSC1210 User Manual
Page 254
Summation/Shifter
17-26
}
switch (convert_accumulate)
{
case CONVERT: //straight A/D conversion results, no averaging
PAI = 0x20;
for (i = 0; i < 0x40; i++)
{
converting = 1;
/*straight conversion idle loop.
Value of ”converting” is changed in the a_to_d_accumulate ()
ISR which is called at the end of each conversion.*/
while (converting);
/*Get LONG integer result and convert to a floating point
voltage value using the proper values for vref and max_value*/
l = read_a_to_d_result ();
voltage_value = (float)l * vref / max_range;
printf (”\nInstantaneous Value: %ld, i.e. %f volts”,
l, voltage_value);
}
break;
default:
//Averaged A/D conversion results
PAI = 0x60;
for (i = 0; i < 0x40; i++)
{
averaging = 1;
/*averaged conversion idle loop.
Value of ”averaging” is changed in the a_to_d_accumulate ()
ISR which is called at the end of each completed
averaging sequence.*/
while (averaging);
/*Get LONG integer result and convert to a floating point
voltage value using the proper values for vref and max_value*/
l = read_accumulator_result ();
voltage_value = (float)l * vref / max_range;
init_accumulator ();
printf (”\nInstantaneous voltage Values ”);
printf (”Averaged Over %d Samples: %ld,\n i.e. %f volts”,
(int)accum_count, l, voltage_value);
}
break;
}
while (1);
}