2018-04-14 08:27 AM
2018-04-15 10:07 PM
Have you solved your issue yet?
Recently, I've interfaced MPU9250 with STM32L476 using LL SPI libraries instead of HAL.
I've ported this Arduino Library to my projects. Worked well for me. You may also try.
https://github.com/brianc118/MPU9250
Initialization codes are little lengthy. The SPI clock might be needed less than 8MHz.
Thank you.
2018-04-16 04:08 AM
I still have the issue. Is using LL SPI libraries much more difficult? Thanks
2018-04-16 11:12 AM
LL SPI libraries are easy to use. I'm using for L4. Not sureLL librariesfor F7 are available or not.
You can use your mpu_write_registercommand and follow the initialization command provided in Arduino GitHub.
Could it possible the chip is enabled for I2C instead of SPI ?
Most of online examples are for I2C.
Thanks
2018-04-18 07:42 AM
I went with I2C for now as that worked. Might be something with the breakout board and SPI.
Thanks2018-04-19 01:36 AM
Hello,
I think there is a problem in function
mpu_read_byte.
You want read two bytes, but the supplied buffer is only one byte long.
In addition, it is often a problem with the unreaded value in the receiving buffer.
Try clear previosly received bytes before callingHAL_SPI_TransmitReceive
function.
2018-04-19 05:25 AM
I cannot comment on your code but your MISO signal is not correct. All logic levels should be 3.3V. There must be a another signal driving the MISO line that should not be there. Either that or something is happening to the 3.3V power supply on the 9250. I would worry about code until that is fixed.
2018-04-19 03:14 PM
Thanks for the answers!
I acquired a new MPU9250 breakout board earlier today and tested again with SPI. This time I got it to work! Seems like there was something wrong with the old breakout board after all.AlsoI had to change the mpu_read_byte function as you stated
Made it a little more general also to be able to read multiple registers from the MPU.
So now it's all good and working correctly with SPI.
Thanks again for the help!
HAL_StatusTypeDef mpu_read_bytes(uint8_t rd_reg, uint8_t *rd_data, uint16_t length){HAL_StatusTypeDef status;uint8_t data_rd_bit = rd_reg | 0x80;HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);if((status = HAL_SPI_Transmit(&hspi1, &data_rd_bit, 1, HAL_MAX_DELAY)) != HAL_OK) {return status;}status = HAL_SPI_Receive(&hspi1, rd_data, length, HAL_MAX_DELAY);HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);return status;}�?�?�?�?�?�?�?�?�?�?�?�?�?�?