AnsweredAssumed Answered

LSM9DS0 SPI trouble STM32F405

Question asked by ebisuzaki.tyler on Nov 7, 2014
Latest reply on Jan 21, 2015 by Mikk Leini
Hi everyone,

this is my SPI configuration used for interfacing with the LSM9DS0 in 4 wire

     RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2 , ENABLE);


    SPI_InitStruct.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
    SPI_InitStruct.SPI_Mode = SPI_Mode_Master;
    SPI_InitStruct.SPI_DataSize = SPI_DataSize_8b; 
    SPI_InitStruct.SPI_CPOL = SPI_CPOL_High; 
    SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;
    SPI_InitStruct.SPI_NSS = SPI_NSS_Soft;
    SPI_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32;
    SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
    SPI_CalculateCRC(SPI2, DISABLE);
    SPI_Init(SPI2, &SPI_InitStruct);
   SPI_SSOutputCmd(SPI2,DISABLE);
   SPI_Cmd(SPI2, ENABLE);

the chip selects are tied to GPIO pins which I have enabled.

When I use an oscilloscope i can see my spi clocking and the cs being pulled low and data being transfered.

I then try to read the who am I register by pulling the appropriate cs low, writing 0b10001111 , write 0b00000000, and then reading the data register and raising the cs
but it always returns 0.

I then try to not raise the cs back up but instead constantly send 0b10001111, 0b00000000 and I'll get rubbish on the miso line so i know i'm connected properly... what am I doing wrong?

This is on an STM32F405  clk speed of 168MHz

edit:
On second thought, what does the lsm9ds0 send if all zeros are written? or what would cause the lsm9ds0 to send random data across? I'm thinking maybe the mosi isn't connected to the lsm9ds0 and it's just clocking in all zeros or all 1s... would this cause random data to be pushed out of the imu?

Outcomes