SLAA475A October   2010  – March 2019 MSP430L092

 

  1.   MSP430x09x Analog Pool: Feature Set and Advanced Use
    1.     Trademarks
    2. 1 MSP430x09x Overview
    3. 2 Analog Pool (A-Pool)
      1. 2.1  Input Dividers
      2. 2.2  Internal Reference
      3. 2.3  Starting and Stopping the A-Pool
      4. 2.4  Comparator Function
      5. 2.5  8-Bit DAC Function
      6. 2.6  8-Bit ADC Function
        1. 2.6.1 ADC Conversion Using Ramp
          1. 2.6.1.1 ADC Conversion Without Error Compensation
          2. 2.6.1.2 ADC Conversions With Overdrive Compensation
          3. 2.6.1.3 ADC Conversions With Offset Compensation
          4. 2.6.1.4 ADC Conversions With Overall Compensation
          5. 2.6.1.5 Windowed ADC Conversion
        2. 2.6.2 ADC Conversion Using SAR
        3. 2.6.3 Multiple ADC Conversions
        4. 2.6.4 Comparison Between Different Measurement Methods
        5. 2.6.5 Error Dependencies
      7. 2.7  SVM Function
      8. 2.8  Use of Multiple Features
      9. 2.9  Temperature Measurements With the A-Pool
      10. 2.10 Fractional and Integer Number Use
      11. 2.11 APINTB and APFRACTB Use With ATBU and EOCBU
      12. 2.12 A-Pool Trigger Sources
      13. 2.13 Filtering ADC Conversions With Digital Filters
    4. 3 Summary
    5. 4 References
  2.   Revision History

ADC Conversions With Overall Compensation

This compensation includes all compensation methods previously mentioned and allows the most accurate measurement. The internal offset and the overdrive error are handled by the following code.

#include "msp430l092.h" unsigned char result[4]; // result array unsigned char i = 0; // counting variable void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; APCNF = CMPON+DBON+CONVON+APREFON; // Enable comparator on + // Enable DAC buffer + // Enable conversion + // Enable reference APVDIV = A0DIV; // Set 500mV input range APINT = 0x00; // clear ADC-DAC-REG APIE |= EOCIE; // Enable end of conversion interrupt _BIS_SR(GIE); // Switch on global interrupts APCTL = APPSEL0+APPSEL2+OSEL+CBSTP+SBSTP; // Set DAC buffer output to PSEL + // Enable DAC buffer + // Enable conversion + // Enable reverence + // Select output buffer + // Enable Comparator based stop + // Enable Saturation based stop + APCTL |= RUNSTOP; // Start conversion _BIS_SR(LPM0); // Go to LPM0 APINT = APINT + 0; // Add an offset for counting APCTL = APPSEL0+APPSEL2+OSEL+CBSTP+SBSTP+SLOPE; // Set DAC buffer output to PSEL + // Enable DAC buffer + // Enable conversion + // Enable reverence + // Select output buffer + // Enable Comparator based stop + // Enable Saturation based stop + // Switch to falling slope + APCTL |= RUNSTOP; // Start conversion _BIS_SR(LPM0); // Go to LPM0 APINT = 0x00; // clear ADC-DAC-REG APCTL = APNSEL0+APNSEL2+OSEL+CBSTP+SBSTP+OSWP; // Set DAC buffer output to NSEL + // Select output buffer + // Enable Comparator based stop + // Enable Saturation based stop + // Inverted comparator output is used + APCTL |= RUNSTOP; // Start conversion _BIS_SR(LPM0); // Go to LPM0 APINT = APINT + 0; // Add an offset for counting APCTL = APNSEL0+APNSEL2+OSEL+CBSTP+SBSTP+OSWP+SLOPE; // Set DAC buffer output to NSEL + // Select output buffer + // Enable Comparator based stop + // Enable Saturation based stop + // Inverted comparator output is used + // Switch to falling slope + APCTL |= RUNSTOP; // Start conversion _BIS_SR(LPM0); // Go to LPM0 asm("nop"); while(1); } #pragma vector=APOOL_VECTOR // A-Pool interrupt service routine __interrupt void APOOL_ISR(void) { switch(__even_in_range(APIV,8)) // Add offset to PC and delete flag { case 0: break; case 2: result[i++] = APINT; // Save value in result array __bic_SR_register_on_exit(CPUOFF); // Exit LPM0 break; case 4: break; case 6: break; case 8: break; default: break; } }