4 burnout current sources – Texas Instruments MSC1210 User Manual
Page 143
Burnout Current Sources
12-7
Analog-to-Digital Converter
12.4 Burnout Current Sources
When the Burnout bit (BOD) is set in the ADC control register (ADCON0.6),
two current sources are enabled that source approximately 2
µ
A.
This allows for the detection of an open circuit (full-scale reading) or short-cir-
cuit (0V differential reading) on the selected input differential pair.
The following program illustrates a simple open-circuit and short-circuit detec-
tion routine.
#include
#include
#include
#include
#define LSB 298.0232e−9
extern void autobaud(void);
extern long bipolar(void);
void main(void)
{
float sample, decimation = 1728;
CKCON = 0; // 0 MOVX cycle stretch
autobaud();
printf(”Brown−Out Detection\n”);
//Timer Setup
USEC= 10; // 11MHz Clock
ACLK = 9; // ACLK = 11,0592,000/10 = 1,105,920 Hz
// modclock = 1,105,920/64 = 17,280 Hz
// Setup ADC
PDCON &= 0x0f7; //turn on adc
ADMUX = 0x01;
ADCON0 = 0x70; // Vref On, Vref Hi, Buff off, BOD on, PGA=1
ADCON2 = decimation & 0xFF;
// LSB of decimation
ADCON3 =(decimation>>8) & 0x07;
// MSB of decimation
ADCON1 = 0x01; // bipolar, auto, self calibration, offset, gain
while(1)
{
while (!(AIE & 0x20));
sample = bipolar() * LSB; // This read clears ADCIRQ
printf (”Sample=%f”, sample);
if(sample < 0.01)
printf(” Short Circuit\n”);
else if(sample > 2.4)
printf(” Open Circuit\n”);
else
printf(“Normal Sensor Range\n”);
while(!RI);
RI = 0;
}// while
} //main