Listing 1—Read the ADC channel for the pressure and use the look-up table to adjust for calibration.
ATD1PE=0x8b; // Enable desired ADC channels (AD3 for pressure, // AD0, AD1, AD7 for x,y,z)
ATD1C=0xE0; // Set prescale to 4-, 8-bit conversion
ATD1SC = 0x03; // Read pressure
while ((ATD1SC & 0x80) != 0x80){}
pressure = ATD1RH;
// Adjust pressure with calibration data
pressure = lut[pressure-81]; // Offset to zero - then index into // calibration table