Skip to main content
Visitor II
October 12, 2013
Question

LSM9DS0 4-wire SPI communication

  • October 12, 2013
  • 3 replies
  • 877 views
Posted on October 12, 2013 at 08:27

hi,guys

I'm working on LSM9DS0 with STMEVAL-MKI109V2,using 4-wire SPI communication?read gyro's WAI reg is ok if keep CS_G=0 and CS_XM = 1 after EVAL board power on, but if CS_G=0 after CS_G=1 and CS_XM = 1,read WAI reg, MCU can't get any response(SDO=0xFF always),can anyone explain me why? I would be grateful if anyone could post LSM9DS0 SPI communication code.

thanks.

#lsm9ds0-4-wire-spi #psm9ds0-purchase
    This topic has been closed for replies.

    3 replies

    Visitor II
    November 7, 2013
    Posted on November 07, 2013 at 23:27

    Hi,

    this is my configuration,

    I am not using an STM32 but I mounted 3 of these devices and they work fine. I have huge problems with the magnetometer in 8 and 12 gauss range and to me this device is not saturating with 12 gauss of magnetic field applied and is starting to behave bad sending weird magnetometer data Data coming out are without any sense. Even with 2 and 4 gauss range after a region the magnetometer is saturated it starts to send weird data when the magnets gets close. The only way to have it working is to use 2 or 4 gauss range ... that is not the way I am intended to use it: :(

    void lsm9ds0_XM_init(){

    P1_1 = LOW;

    U1TX_BYTE = 0;

    U1DBUF = CTRL_REG1_XM;

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    U1DBUF = (ACC_400_Hz_A | xyz_en_A);

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    P1_1 = HIGH;

    halMcuWaitUs(10);

    P1_1 = LOW;

    U1TX_BYTE = 0;

    U1DBUF = CTRL_REG5_XM;

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    U1DBUF = (M_HRES | M_0DR_100);

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    P1_1 = HIGH;

    halMcuWaitUs(10);

    P1_1 = LOW;

    U1TX_BYTE = 0;

    U1DBUF = CTRL_REG6_XM;

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    U1DBUF = (M_FS_2); // 2 Gauss Range

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    P1_1 = HIGH;

    halMcuWaitUs(10);

    P1_1 = LOW;

    U1TX_BYTE = 0;

    U1DBUF = CTRL_REG7_XM;

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    U1DBUF = (M_CONV_CONT);

    while (!U1TX_BYTE);

    U1TX_BYTE = 0;

    P1_1 = HIGH;

    }

    You can find the settings in this part I just copied here from my attached header file

    ________________

    Attachments :

    lsm9ds0.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzJn&d=%2Fa%2F0X0000000bJi%2FVCwhmQHMEHIKqpq4RugE5d3YXd1DP_FENUr9TM5Ijsw&asPdf=false
    Visitor II
    November 28, 2013
    Posted on November 28, 2013 at 20:31

    Hi.

    How did you purchase the LSM9DS0 module to plug into the eval board? I have the base eval board, but am told the LSM9DS0 plug in is not ready yet.

    Dave Bassett

    Visitor II
    February 5, 2014
    Posted on February 05, 2014 at 13:00

    Hello David,

    In order to obtain the LSM9DS0 module for the emotion board you will have to provide me at

    mailto:thiago.reis@st.com

     the below information so I can re-direct you for your ST´s local representatives.

    - Application

    - Company

    - Location

    - Anual production volume

    Thank you very much,

    Thiago REIS