

//ISR for I2C Bus ADC data Receive.
void i2c_isr(void) interrupt 11 using 1
{
    uchar bt2;           // Variable to store adc data
    uint bsqr;		 // Variable to store square data.
    bt2=I2DAT;		 // Fetch data from ADC
    bsqr=bt2*bt2;	 // Square it.

    t1lock=0;    	// Flag set by timer 1 interrupt when it occurs.
    MSSUM+=bsqr;
    samples++;

    if (t1lock)  	// If timer 1 interrupt had occured while above computations
    {
	MSSUM=0;	// Make MSSUM and samples zero.
	samples=0;
    }
    I2CON&=0xF7;	// SI=0
}

