Post Go back to editing

Unusual return value on Read ID

Category: Software
Product Number: ADXL313
Software Version: CMSIS

Hello -

A bit of a red face asking this question, but I've been spinning my wheels looking for a cause but unable to find one. I am using the ADXL313/SEN-17241 from Sparkfun. Connected to this is a NUCLEO-L452RE-P development board. One I am familiar with and used many times.I have verified that all 4 lines (6 with pwr/Gnd) are connected correctly.

I used CubeMX to configure the SPI3 interface to meet the specification for CPOL to HIGH and CPHA to 1 edge. Data is set to 8 bits, MSB first. Baud rate is 250kbits. Here is the read ID function - I've created this specifically for an ID read (although I do have a general read function)

uint8_t ADXL313_ReadID( void )
{
    uint8_t spiData;
    uint8_t reg = ADXL313_REG_DEVID | 0x80;  // Set MSB for read operation
    
    ACC_CS_ASSERT();    //sets LOW
    HAL_SPI_Transmit(&hspi3, &reg, 1, HAL_MAX_DELAY);
    HAL_SPI_Receive(&hspi3, &spiData, 1, HAL_MAX_DELAY);
    ACC_CS_DEASSERT();  //sets HIGH 
    
    return spiData;
}

I have checked the CS pin on the target board and it is HIGH when I breakpoint at the ACC_CS_ASSERT. Yet, I can only get back a value of 0xD6. Now with the exception of register addresses this code is pretty much identical to code I am using on an ST part, the LIS331DLH, and it works just fine.

So...what in the world might the problem be? Anyone seen this before? (next will be dragging out the scope)

Thanks! Gary.

Parents
  • Hello -

    Can someone please advise on this question.

    Without setting any registers, and after power up in 4 wire SPI mode, should I be able to read the device ID?

    If not, what register(s) need to be set first, and to what value?

    Currently doing this:

    Power on - wait 500ms - ReadID - getting back 0xD6 == BAD! For clarity, here is slightly changed function to readID.

    uint8_t ADXL313_ReadID( void )
    {
        uint8_t spiData;
        uint8_t reg = ADXL313_REG_DEVID;
        
        ACC_CS_ASSERT();    //set CS low
        HAL_SPI_TransmitReceive(&hspi3, &reg, &spiData, 1, HAL_MAX_DELAY);
        ACC_CS_DEASSERT();  //set CS high 
        
        return spiData;
    }

    Thanks,

    Gary

Reply
  • Hello -

    Can someone please advise on this question.

    Without setting any registers, and after power up in 4 wire SPI mode, should I be able to read the device ID?

    If not, what register(s) need to be set first, and to what value?

    Currently doing this:

    Power on - wait 500ms - ReadID - getting back 0xD6 == BAD! For clarity, here is slightly changed function to readID.

    uint8_t ADXL313_ReadID( void )
    {
        uint8_t spiData;
        uint8_t reg = ADXL313_REG_DEVID;
        
        ACC_CS_ASSERT();    //set CS low
        HAL_SPI_TransmitReceive(&hspi3, &reg, &spiData, 1, HAL_MAX_DELAY);
        ACC_CS_DEASSERT();  //set CS high 
        
        return spiData;
    }

    Thanks,

    Gary

Children
No Data