Summation/Shifter

while(!(AISTAT & 0x20)); j = ADRESL;

for (i = 0; i < 20; i++) { // dump 20 conversions /*wait for DRBY bit*/

while(!(AISTAT & 0x20));

}

/*set up Summation / Shifter*/ /*Select Summation / Shifter option, Acc Count = 8, Shift Count = 8

*/

init_accumulator ();

//extract Accumulate−Count from SSCON SFR Register. j = SSCON & 0x38;

j /= 8;

j = 1 << (j + 1); return (j);

}

void a_to_d_accumulate (void) interrupt 6 using 1

{

/*interrupt type 6 vectored to 0x33.

Any AI type interrupt would come to this ISR. Evaluating the SUM and ADC bits of AISTAT will determine whether the ISR call was due to the A/D Converter interrupt or the Summation/Shifter interrupt*/

if (AISTAT & 0x20)

{//A/D conversion interrupt converting = 0;

AISTAT &= ~0x20; /*clear ADC bit*/

}

if (AISTAT & 0x40) {//Accululator/Shifter interrupt

averaging = 0;

AISTAT &= ~0x40; /*clear SUM bit*/

}

return;

}

void main(void)

{

int i;

17-24

Page 252
Image 252
Texas Instruments MSC1210 manual 17-24