BMX150 Firmware Info Doc
The purpose of this article is to give a brief overview of the most important functions of the BMX150 9-axis sensor as it relates to the EFS team.
Data sheet: https://www.mouser.com/pdfdocs/BST-BMX160-DS000-11.pdf
Any numbers in brackets after section titles are the corresponding sections in the data sheet, in case more information is required.
Operation
The BMX150 is a low power, small footprint device that serves as an accelerometer, gyroscope and magnetometer. It is capable of communication using I2C and SPI, however in this article we will only be using SPI.
List of registers we care about:
Protocol Selection:
At power up, the device is in I2C mode. In order to change it to SPI mode, CSB must see a rising edge after power up. If the device is powered off or reset, the BMX150 will revert back to I2C mode and must be again set to SPI mode. The data sheet recommends to perform a SPI single read access to the ADDRESS 0x7F before the actual communication to use the SPI interface.
There is also the spi_en bit in Register (0x70) NV_CONF, which can be used to permanently set the interface to SPI mode. The BMX150 can also be used in a 3 wire SPI mode, but this is not of interest to us currently.
How to trigger a self-test/calibration:
Refer to section 2.11.33 for the bits in the (0x6D) SELF_TEST register.
Self test accelerometer (2.8.1):
Set the accelerometer to normal mode. Do this by writing value 0x11 to Register (0x7E) CMD.
The Register (0x40) ACC_CONF has to be set to value 0x2C and the Register (0x41) ACC_RANGE has to be set to value 0x08 for the accelerometer self test mode to function properly.
Write the value 0b01 to the acc_self_test_enable bits (bits 0 and 1) in the Register (0x6D) in order to activate the self test.
The direction of the deflection of all 3 axes can be controlled using acc_self_test_sign bit; they are negative or positive depending on if acc_self_test_sign = 0b0 or 0b1, respectively.
Perform the self test in both the positive and negative directions and then calculate the difference between the resulting acceleration values in order to ensure proper interpretation of the self test signal. The minimum absolute difference between the measured positive and negative values for each axis should be 2g. It is fine if they are significantly higher.
Reset the device after the test is complete.
Self test gyroscope (2.8.2):
Write a 1 to the gyr_self_test_enable bits (bits 0 and 1) in the Register (0x6D) in order to activate the self test.
The result will be found in gyr_self_test_ok in Register (0x1B) STATUS.
Self test magnetometer (2.8.3, refer to ):
Set the magnetometer to normal mode. Do this by writing value 0x19 to Register (0x7E) CMD.
Put the magnetometer in setup mode by setting mag_manual_en in Register (0x4C-0x4F) MAG_IF to 1.
Put the magnetometer into sleep mode? the data sheet doesn’t give any details on this
Put the magnetometer in self test mode by setting Register 0x4C bit0 to 1.
wtf is mag register read/write??