06-08-2022 01:12 PM
The datasheet says on page 89 (chapter 3.2.1 - Primary interface i2c/spi protocol selection) that a rising edge on CS is needed to switch to SPI:
"At reset / power-up, BMI160 is in I2C mode. If CSB isconnected to VDDIOduring power-up and not changed the sensor interface works in I2C mode.For using I2C, it is recommended to hard-wire the CSB line to VDDIO. Since power-on-reset is only executed when,both VDDand VDDIOare established, there is no risk of incorrect protocol detection due to power-up sequence.If CSB sees a rising edge after power-up, the BMI160 interface switches to SPI until a reset or the next power-up occurs.Therefore, a CSB rising edge is needed before starting the SPI communication"
Is there a time limit for this or it will automatically switch to SPI even if the cs low/high edge comes later (let's say 1ms) after power up ?
I have a board where the main cpu and the sensor are powered from a battery and I have the sensor wired to us SPI, is it enough to just do a dummy write (as the datasheets says) right after boot to trigger the switch to SPI or should I redesign the board so that the cpu controls the sensor's VDD pin
Currently I am doing a dummy SPI read from 0x7e right after boot, then I can read the chip id and it has a correct value, but I was wondering if this may glitch from time to time or is it safe to keep as it is?
I saw this as an example (but would require me redesign the board): set CS low, turn on sensor (apply power to VDD), set CS high.
Thank you.
Solved! Go to Solution.
06-08-2022 03:58 PM
Hi,
Thanks for your inquiry.
You don't need to redesign your board to follow that example and it is safe for you to keep the way you are doing.
After BMI160 os powered on, it will take less than 10ms to finish the POR (power-on-reset at page 13 of BMI160 datasheet). Then BMI160 will be in suspend mode with default I2C interface. Now you can do a dummy read at any register for example 0x7E or 0x7F or 0x00, etc. through SPI interface. BMI160 will automatically switch to SPI interface. If there is no soft-reset or another POR during operation, then BMI160 will always stay in SPI interface.
By the way, BMI160 has been discontinued. Please switch to BMI270 which is pin-to-pin compatible with BMI160.
Thanks.