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.

CCS/MSP430FG4618: ADC Reading from 3-axis accelerometer adxl335.

Part Number: MSP430FG4618

Tool/software: Code Composer Studio

Dear,

I am having an issue reading the data from 3-axis accelerometer adxl335 using adc. I can only read correctly x-y or x-y at the same time. I cannot read correctly x-y-z at the same time. Will someone please check if my adc configuration is correct? Thank you!

void ADC_setup(void) { int i =0; P6DIR &= ~(BIT3 | BIT4 | BIT7); // Configure P6.3, P6.4 and P6.7 as input pins P6SEL |= BIT3 | BIT4 | BIT7; // Configure P6.3, P6.4 and P6.7 as analog pins /* ***** ADCCore configuration ***** */ /* Reset REFMSTR to enable control of reference voltages by ADC12 */ ADC12CTL0 &= ~ENC; /* * Initialize control register ADC12CTL0 * ADC12ON = 1 => Turn on ADC12 * STH0x = 9 => Sample-and-Hold time takes 384 clock cycles * MSC = 1 => ADC12 Multiple Sample Conversion */ ADC12CTL0 = ADC12ON | SHT0_9 | MSC; // Configure ADC converter /* * Initialize control register ADC12CTL1 * SHP = 1 => Sample/Hold Pulse Mode * CONSEQx = 1 => Conversion sequence mode: Sequence of Channel */ ADC12CTL1 = SHP | CONSEQ_1; // Use sample timer, single sequence /* ***** Channels configuration ***** */ ADC12MCTL0 = INCH_3; // ADC A3 pin - Stick X-axis ADC12MCTL1 = INCH_4; // ADC A4 pin - Stick Y-axis ADC12MCTL2 = INCH_7 | EOS; // ADC A7 pin - Stick Z-axis // EOS - End of Sequence at ADC12MCTL2 ADC12IE |= 0x04; // Enable ADC12IFG.1 at BIT2 (the EOS ADC Channel) for (i = 0; i < 0x3600; i++); // Delay for reference start-up ADC12CTL0 |= ENC; // Enable conversions } void main(void) { WDTCTL = WDTPW +WDTHOLD; // Stop WDT TimerA_setup(); // Setup timer to send ADC data ADC_setup(); // Setup ADC UART_intilize(); // Setup UART for RS-232 _EINT(); while (1){ __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 } } #pragma vector = ADC12_VECTOR __interrupt void ADC12ISR(void) { ADCXval = ADC12MEM0; // Move results, IFG is cleared ADCYval = ADC12MEM1; ADCZval = ADC12MEM2; __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 } #pragma vector = TIMERA0_VECTOR __interrupt void timerA_isr() { ADC12CTL0 |= ADC12SC; // Start conversions every 0.25s __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 }

Best,

Tony

**Attention** This is a public forum