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
#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 _
In the zip are all pictures (there are more than 2)…
OSzi.rar (126 KB)