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/RM46L852: Getting Data from ADXL313Z Accelerometer

Part Number: RM46L852
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

I have been trying to get data from the ADXL313Z accelerometer on the Hercules LaunchPad Development Kit using mibSPI, but have failed to get any values. I have generated code with Halcogen to use on Code Composer Studio. The PINMUX is set to Pin 3 MIBSPI3NCS_3, Pin 51 MIBSPI3SOMI, Pin 52 MIBSPI3SIMO, and Pin 53 MIBSPI3CLK. Everything else is set to its default values.  I have been running the following code to try to get data:

mibspiInit();
    uint16_t rxBuffer[8];

    while(1){
        mibspiGetData(mibspiREG3, 0, rxBuffer);
    }

I tried looking at the voltage of the chip select to see if the board was attempting to send any data, but it seemed that the board wasn’t even trying to send anything.

I would really appreciate some help in solving this problem.

  • Hello Chris,

    1. I don't think our Hercules Launchpads has ADXL313 accelerometer on it. I used LIS344A accelerometer on one very old USB kit before, and this accelerometer outputs 3 analog signals 9X, Y, Z).

    2. Do you follow the SPI communication protocol defined in ADX313 datasheet (Figure 18, 19)? You need to send command first, then read the returned value from ADXL313.

    3. I recommend to use spiTransmitAndReceiveData() for polling mode, or spiSendAndGetData() for interrupt mode.

  • Hi QJ,

    I have an ADXL313Z Eval Board connected to the Hercules Launchpad. I'm also referencing this forum post https://e2e.ti.com/support/microcontrollers/hercules/f/312/p/403921/1440140 and tried using this code to get the register ID:

    int main(void)
    {
    /* USER CODE BEGIN (3) */
        static spiDAT1_t dataConfig =
        {
            .CS_HOLD = 1,
            .WDEL = 1,
            .DFSEL = SPI_FMT_1,
            .CSNR = SPI_CS_3
        };
        spiInit();
    
        uint16 tx_data[8] = {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
        uint16 rx_data[16] = {0};
    
        while(1){
            spiTransmitAndReceiveData(spiREG3, &dataConfig, 1, tx_data, rx_data);//gives value 0xD6D6?
        }
    /* USER CODE END */
    }

    The default value stored at this register should be the chip ID, which is 0xAD, but it keeps giving the value 0xD6D6. 

    I don't really understand what is going on and what has gone wrong with the code, so I'd really appreciate if your help. 

  • Hello,

    What is charlen used in your SPI configuration: 8 bits or 16 bits? What is the expected return value for the device ID?

    If you use 8bit charlen, you need to modify the parameter in the SPI functions: changing uint16 to uint8

    uint32 spiTransmitAndReceiveData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 blocksize, uint16 * srcbuff, uint16 * destbuff);

    Can you let me know the communication protocol for ADXL313Z?

    What does 0x80 mean in your tx_data[]?