Texas Instruments MSC1210 manual Keil Simulator 17-23

Models: MSC1210

1 324
Download 324 pages 20.97 Kb
Page 251
Image 251

Summation/Shifter

to a LONG integer*/ long j;

j = ACR3; j <<= 8; j += ACR2; j <<= 8; j += ACR1; j <<= 8; j += ACR0;

return (j);

}

long read_a_to_d_result ()

{

long j;

/*Convert A/D Conversion results from the ADRESH:ADRESM:ADRESL register string to a LONG integer ith sign extension*/

j = ADRESH; j <<= 8;

j += ADRESM; j <<= 8;

j += ADRESL;

j &= 0x00ffffff; //eleminate upper nibble if (j & 0x00800000)

{//is result negative? j = 0x0ff000000;

}

return (j);

}

char init_a_to_d ()

{

char i, j;

/* Setup ADC */

//ADCON0 = 0x30; // Vref on 2.5V, Buff on, BOD off ADCON0 = 0x20; // Vref on 1.25V, Buff on, BOD off

ADCON1 = 0X00;

ADCON2 = 0xFF; // decimation ratio

ADCON3 = 0x00;

ADCON1 = 0x05; // bipolar, Filter = auto, self calibration, offset, gain //wait for the calibration to take place

printf (”\n\nCalibrating....\n”);

Keil Simulator

17-23

 

Page 251
Image 251
Texas Instruments MSC1210 manual Keil Simulator 17-23