This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F2619: ADC12 ACCELEROMETER.

Part Number: MSP430F2619


Hello. I have msp430f2619 and an accelerometer from which an analog signal comes to pins 6.0-6.3 respectively zyx and temperature. 
I'm new to programming microcontrollers, and I would like to understand what kind of numbers do I get with the code below?
Even if the accelerometer is not moved, the incoming signal still ranges from 1050 to 1200 ..
Help the beginner with advice, thanks in advance!

#include <msp430.h> #define Num_of_Results 8 volatile unsigned int A0results[Num_of_Results]; volatile unsigned int A1results[Num_of_Results]; volatile unsigned int A2results[Num_of_Results]; volatile unsigned int A3results[Num_of_Results]; int main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer P6SEL = 0x0F; // Enable A/D channel inputs ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, extend sampling time // to avoid overflow of results ADC12CTL1 = SHP+CONSEQ_3; // Use sampling timer, repeated sequence ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0 ADC12MCTL1 = INCH_1; // ref+=AVcc, channel = A1 ADC12MCTL2 = INCH_2; // ref+=AVcc, channel = A2 ADC12MCTL3 = INCH_3+EOS; // ref+=AVcc, channel = A3, end seq. ADC12IE = 0x08; // Enable ADC12IFG.3 ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start convn - software trigger __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, Enable interrupts } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=ADC12_VECTOR __interrupt void ADC12ISR (void) #elif defined(__GNUC__) void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void) #else #error Compiler not supported! #endif { static unsigned int index = 0; A0results[index] = ADC12MEM0; // Move A0 results, IFG is cleared A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared A3results[index] = ADC12MEM3; // Move A3 results, IFG is cleared index = (index+1)%Num_of_Results; // Increment results index, modulo; Set Breakpoint1 here if (index == 0) __no_operation(); // Set Breakpoint2 here }
  • Hi Aleksandr,

    The way you interpret the data coming out of the ADC module is based on the resolution and the reference voltage. Based on your code, it looks like you are using the 12-bit ADC with AVCC as Vref+ and AVSS as Vref-.

    You can refer to the device family user's guide for a detailed explanation in the ADC12 chapter of how to interpret the ADC data into measured analog voltages. These voltages would correspond to the channel being measured from the accelerometer. The small changes in ADC values you are seeing are a result of electrical noise. Section 23.2.8 addresses tips and tricks you can use to reduce noise errors.

    Best regards,

    Matt

**Attention** This is a public forum