2
\$\begingroup\$

I've setup the behaviour of LIS302DL accelerometer IC using following code:

void initAccel(void)
{
    accelMeterInt.Latch_Request=LIS302DL_INTERRUPTREQUEST_NOTLATCHED;//LIS302DL_INTERRUPTREQUEST_LATCHED;
    accelMeterInt.SingleClick_Axes=LIS302DL_CLICKINTERRUPT_XYZ_DISABLE;
    accelMeterInt.DoubleClick_Axes=LIS302DL_DOUBLECLICKINTERRUPT_XYZ_DISABLE;

    accelMeter.Power_Mode=LIS302DL_LOWPOWERMODE_ACTIVE;
    accelMeter.Output_DataRate=LIS302DL_DATARATE_400;
    accelMeter.Axes_Enable=LIS302DL_X_ENABLE|LIS302DL_Y_ENABLE|LIS302DL_Z_ENABLE;
    accelMeter.Full_Scale=LIS302DL_FULLSCALE_9_2;
    accelMeter.Self_Test=LIS302DL_SELFTEST_NORMAL;

    LIS302DL_InterruptConfig(&accelMeterInt);
    LIS302DL_Init(&accelMeter);

    delay(ACCEL_METER_DELAY);
}   // init Accel

After using this code, I issue WHO_AM_I command with:

LIS302DL_Read(&ident,
    LIS302DL_WHO_AM_I_ADDR,
    sizeof(ident));

Ident contains 0011 1111 after this call, but according to LIS302DL datasheet, it should containt 00111011. Is there something wrong/my code does not work and if so, why? I am using ST32F4Discovery board with IAR Embedded Workbench IDE.

\$\endgroup\$
  • 1
    \$\begingroup\$ Might just be a typo, but shouldn't the first argument to LIS302DL_Read() be a pointer, i.e. &ident? \$\endgroup\$ – fm_andreas Oct 20 '13 at 21:34
  • 1
    \$\begingroup\$ Yes, thank you, it is a pointer, I've already corrected that in the code, but I think I have Discovery version with LIS3DSH aceelerometer (which has WHO_AM_I code 0x3f), but I am now reading both datasheets, LIS3DSH is very different than LS302DL and I cannot find LIS3DSH library to work with in a project... \$\endgroup\$ – KernelPanic Oct 21 '13 at 9:44
  • \$\begingroup\$ You don't really need a library specific to LIS3DSH. You just need an I2C or SPI (depending on your setup) library. ST has a free library with this functionality: st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1897 \$\endgroup\$ – Chad Kennedy Feb 3 '16 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.