Hi
I was trying to post my question in this thread, however, it is locked!
I am connecting the MSP430G2553 to the ADXL345 accelerometer over SPI and using this code to set the ADXL345:
/////////////////////////////////////////////////////////////////// void SPI_write(void){ P3OUT &= ~CS; // BIT 3.7 is CS while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x2D; // We want to write to the power register while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x00; // Write the 0x00 to the power register (put the ADXL345 in standby mode) ///-------------------------------------------------------- while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x31; // We want to write to the data format register while the ADXL345 is in stanby mode while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x09; // Write the 0x01 to the data format register (4g range) ///-------------------------------------------------------- while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x2C; // We want to write to the BW_RATE register while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x09; // Write 0x09 to the BW_RATE register to set the ACC to 25Hz data rate (table 7, p#14 of datasheet) // setting the ACC to this acceleration sampling rate should makes it consume 90microAmp. //see note 7 on page 5 of the data sheet about the wake up time ///--------------------------------------------------------- while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x2D; // We want to write to the power register while (!(IFG2&UCA0TXIFG)); // Wait for TXBUF ready UCA0TXBUF = 0x08; // Write the 0x08 to the power register to put it in measure mode ///--------------------------------------------------------- delay_ms(10); while (!(UCB0STAT&UCBUSY)==0); IFG2 &= ~UCA0RXIFG; P3OUT |= CS; } ////////////////////////////////////////////////////////////////////////
I am getting back the data. But it is different from when the ADXL345 is connected to the Arduino.
For example, when he accelerometer is still on the table, then I get 0.79 G rather than 1 G for the z-axis
anyone can help me with this
thank you