I'm using a BMX160 with an ARM Microprocessor, using I2C, code developed in C, using the MCUXpresso IDE to program the micro. I've got the accelerometer, gyro and magnetometer working as expected. The ARM board outputs a data stream to a tool on my pc that graphs the sensor values for all 9 axes.
When I program the board (through a USB connection) and run the software from my pc all is working correctly.
When I disconnect the board from the usb connection, hard reset my electronics (power off power on, including the BMX160), the magnetometer does not provide any output data, but the accelerometer and gyro work as previously.
I assumed it was a power-on start up race condition with the BMX160 and added delays of up to a second in the start up code before attempting to access any sensor registers, but this made no difference. I tried a softreset of the BMX160 (CMD register 0x7e set to 0xB2), a soft reset of the magnetometer, and a POR reset of the magnetometer, all with no success.
Also checked that I'm not exceeding the power capabilites of the supply on my board.
I think I'm missing something but can't find it.
Any insight from anyone please?
Here is the my example project based on Arduino.
What you have to do is to change i2c write read functions and delay function in your own.
(bmx160_hal_i2c_bus_read, bmx160_hal_i2c_bus_write bmx160_delay_usec functions. )
Currently, my example is FIFO, but you can find other output method in github.
I recommend github API, because BMX160 is actually BMI160 + BMM150 inside.
So, for magnetometer sensor BMM150, you need to configure inside interface like this.
/* Auxiliary function definitions */
int8_t bmm150_aux_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr)
return bmi160_aux_read(reg_addr, reg_data, length, &bmi160dev);
int8_t bmm150_aux_write(uint8_t reg_addr, uint8_t *reg_data, uint32_t length, void *intf_ptr)
return bmi160_aux_write(reg_addr, reg_data, length, &bmi160dev);
I don't think you did it.
Thanks - I got it fixed. Went back and reviewed all my set up values carefully and found a couple of errors. Corrected those and all now works.
Weird symptom though - works when connected to the pc, but doesn't work after a reset when not connected to the pc.
Thanks for your help.