Texas Instruments MSC1210 User Manual

Page 253

Advertising
background image

Summation/Shifter

17-25

Keil Simulator

char accum_count;

long l;

float

voltage_value, vref, max_range;

char convert_accumulate;

convert_accumulate = 1; //Select data averaging option.

CKCON &= 0xf8; // 0 MOVX cycle stretch

//set Serial # 1 indow up for output display

setport ();

printf (”\nMSC1210 Ver:”);

printf (”\nA/D Res H/M/L\t”);

printf (”Acc Reg 3/2/1/0\n”);

//Enable global interrupt and enable Power Fail Interrupt

IE = 0x80;

EPFI = 1;

//initialize A/D converter and extract Accumulation−Count

accum_count = init_a_to_d ();

//Wait for conversion to be completed

while (!(AISTAT & 0x20));

//Conversion completed, then read result of the A/D converter

l = read_a_to_d_result ();

//set conversion constants max_range and vref

if (ADCON1 & 0x40) //is polarity unipolar or bipolar?

{//unipolar

max_range = 0xFFFFFF;

}

else

{//bipolar

max_range = 0x7FFFFF;

}

if (ADCON0 & 0x10) //is Vref = Vrefh or Vref = Vrefl?

{//Vrefh

vref = 2.5;

}

else

{//Vrefl

vref = 1.25;

Advertising