SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the Movement & IMU category should be posted in this forum.
User avatar
By ogris
#204873
I tried to work with mbed LPC1768 and LSM6DS3-Dev-Board from Sparkfun.

The connections:
uC - LSM6DS3
VOUT 3V3 regulated Out - 3V3
GND-GND
SCLK-SCL
MOSI-SDA (SPI SDI)
MISO-SA0
CS-CS
Code: Select all
    #include "mbed.h"
     
    Serial pc(USBTX,USBRX);
    SPI spi(p11, p12, p13); // mosi, miso, sclk
    DigitalOut cs(p14);
     
     
    int main() {
        pc.baud(115200);
        pc.printf("Start");
        spi.format(8,3);
        spi.frequency(100000); 
        // Select the device by seting chip select low
        cs = 1;
        wait(1); 
        
        //Set Register to Default Mode
        //Set SPI to 4 Wire-Mode
        cs = 0;
        spi.write(0x12);
        spi.write(0x04);
        cs = 1;
        wait_ms(1);
        
        uint8_t result;       
        while(1){
            //Select chip
            cs = 0;
            //address
            spi.write(0x8F);
            // send a dummyvalue of 0 to read the first byte returned:
            result = spi.write(0x00);
            //deselect chip
            cs = 1;
            // Send 0x8f, the command to read the WHOAMI register
            printf("WHOAMI register = 0x%X  \n ", result);
             wait_ms(1);
        }
    }
It returned 0x7F every time.

So I checked all bits with the Osziloskop.
Channel 1 - yellow, Channel 2 - blue
Name <Channel1>_<Channel2>
In the zip are all pictures (there are more than 2)...
You do not have the required permissions to view the files attached to this post.
User avatar
By TS-Chris
#204880
Hello, and thanks for your post!

Couple of things you might check.
1- The board ships configured for I2c rather than SPI. If you haven't changed the mode, it's not going to work. You can enable SPI by opening the address select jumper on the top of the board.the board in SPI.
2- Make sure your any boar you're using has 3.3 volt I/O. I'm pretty sure the mbed is a 3.3 volt board, but if you test with another controller, it needs to have 3.3 volt logic as well or you risk damaging the board

Also, we don't support this board under the mbed, you might try using our hookup guide and code on an Arduino Uno first and then when you have things working, move back over to the mbed.