AnsweredAssumed Answered

STM32CubeF4, SPI and MEMS - unable to communicate

Question asked by scarpi.giuseppe on Mar 25, 2015
Latest reply on Mar 30, 2015 by BoatYesterday
I am experimenting STM32 by using a STM32F429I discovery board, with a MEMS on board.
At the moment, any attempt to read the MEMS via SPI by using the Cube libraries has failed.
On the other hand, another example project (not Cube based) is working, so the MEMS itself is surely not defective.

The initialisation code should be OK because it was generated with CubeMX.

Please find here the code I am using, can anyone point me to the error?

Also note that I am executing the code with a debugger, so I can actually read the results of the

Apologies if my question is stupid, I've started with STM32 only since a few days...


    command[0] = 0x20;        // program control register 1
    command[1] = 0x0f;        // turn on device
    
    if (HAL_SPI_Transmit(&hspi5,command,2,100) != HAL_OK)
        (... warns the user of a problem and stop)

    command[0] = 0x8f;        // read whoami

    if (HAL_SPI_Transmit(&hspi5,command,1,100) == HAL_OK)
    {
        // result should be 0b11010100
        HAL_SPI_Receive(&hspi5,memsBuffer,1,100);
        whoami = memsBuffer[0];
  }

Outcomes