Arduino Due SPI Problem with LSM6DS3

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
Posts: 13
Joined: Thu Feb 09, 2012 10:35 pm

Arduino Due SPI Problem with LSM6DS3

Post by randomvibe » Mon May 02, 2016 12:10 pm

I've been having a rough time communicating with my Sparkfun LSM6DS3 IMU. Can't even get it to send the WHO_AM_I value. No matter what I do, the code below returns 255. I tried another LSM6DS3 chip, but same issue. I2C works for both so the chips are functioning.

The Arduino Due pinout diagram shows +5V next to the SPI MOSI pin. Are the MOSI/MISO +5V pins? My IMU is a 3.3V device. Could this be the problem? Or maybe the code below is wrong? Appreciate your help.

Code: Select all

#include <SPI.h>

#define SSX  10

void setup() {

    uint8_t  result1, result2;
    uint8_t  target = 0X0F;

    pinMode(SSX, OUTPUT);
    digitalWrite(SSX, HIGH);   

    SPI.setDataMode(SSX, SPI_MODE3);
    SPI.setClockDivider(SSX,10);        // Due: (pin,divider) where divider is any value from 1 to 255


    digitalWrite(SSX, LOW);             // Select chip

        result1 = SPI.transfer(SSX, 0x80 | target, SPI_CONTINUE); 
        result2 = SPI.transfer(SSX, 0x00, SPI_LAST);
    digitalWrite(SSX, HIGH);            // De-select chip

    Serial.println("Who Am I:");

void loop() {

Post Reply