06-06-2021 11:06 PM - edited 06-06-2021 11:17 PM
Hi
I followed the process as shown in Table 16 in the BMX160 datasheet
_writeByte(BMX160_COMMAND_REG_ADDR, BMX160_MAG_IF_NORMAL_MODE);
ThisThread::sleep_for(1ms);//sleep 650 uS
//Enable magnetometer register access (setup mode)
_writeByte(BMX160_MAG_IF_0_ADDR, BMX160_MAG_IF_SETUP_MANUAL_EN);
//put MAG into sleep mode.
// write 0x01 to MAG 0x4B register
_writeByte(BMX160_MAG_IF_3_ADDR,0x01);
_writeByte(BMX160_MAG_IF_2_ADDR,0x4B);
//MAG lowpower XY preset.
// write 0x01 to MAG 0x51 register
_writeByte(BMX160_MAG_IF_3_ADDR,BMX160_MAG_XY_LP_PRESET);
_writeByte(BMX160_MAG_IF_2_ADDR,BMX160_MAG_CONF_XY_PRESET_ADDR);
//MAG regular Z preset.
// write 0x01 to MAG 0x51 register
_writeByte(BMX160_MAG_IF_3_ADDR,BMX160_MAG_Z_REGULAR_PRESET);
_writeByte(BMX160_MAG_IF_2_ADDR,BMX160_MAG_CONF_Z_PRESET_ADDR);
//set ODR to 12.5 HZ
_writeByte(BMX160_MAG_CONF_ADDR, BMX160_MAG_ODR_12_5HZ);
//put MAG_IF into lowpower mode
_writeByte(BMX160_COMMAND_REG_ADDR, BMX160_MAG_IF_LOWPOWER_MODE);
/* map data ready to INT1 */
_writeByte(BMX160_INT_ENABLE_1_ADDR, BMX160_DATA_RDY_INT_EN );
_writeByte(BMX160_INT_MAP_1_ADDR, BMX160_INT1_DATA_READY);
// prepare MAG_IF[1-3] for mag_if data mode
_writeByte(BMX160_MAG_IF_3_ADDR,0x02);
_writeByte(BMX160_MAG_IF_2_ADDR,0x4C);
_writeByte(BMX160_MAG_IF_1_ADDR,0x42);
//Enable magnetometer data mode
_writeByte(BMX160_MAG_IF_0_ADDR, BMX160_MAG_RD_BURST_8);
I sniffed these commands using logic Analyzer and I can see clearly that all commands have Ack from BMX160 but after sending 0x01 to 0x4C register (to switch to MAG force mode), it gives NACK responses as shown in the figure below.
Any idea what is happening ? I also mentioned that when I disable the Channel X-Y-Z from 0x4E (bmm150 datasheet), the chip doesn't goes to NACK mode and I can receive data ready interrupts, but all MAG Data is only a small fixed number (= 0x0001).
Note:The ACC and GYRO stop working after configuring the MAG
Solved! Go to Solution.
06-07-2021 07:36 AM
Hello YahyaTawil,
There was example code in github "How to use an auxiliary sensor or magnetometer with the BMI160.", you could refer and run it.
https://github.com/BoschSensortec/BMI160_driver/wiki/How-to-use-an-auxiliary-sensor-or-magnetometer-....
06-07-2021 08:08 AM - edited 06-07-2021 09:33 AM
Yes I saw it to check if I'm missing something. My question is regards the Table 16 in BMX160, I followed exactly the same steps but again once I put the MAG into force mode the chip stops acknowledging the I2C.
Note: I map BMX160 Data ready interrupt to INT1. Does the MAG_IF uses any INT pin internally So I should avoid using it externally ?
Here is the log from my Logic Analyzer:
Start
h68 WR
ACK
h7E
ACK
hB6
ACK
Stop
Start
h68 WR
ACK
h7E
ACK
h19
ACK
Stop
Start
h68 WR
ACK
h4C
ACK
h80
ACK
Stop
Start
h68 WR
ACK
h4F
ACK
h01
ACK
Stop
Start
h68 WR
ACK
h4E
ACK
h4B
ACK
Stop
Start
h68 WR
ACK
h4F
ACK
h01
ACK
Stop
Start
h68 WR
ACK
h4E
ACK
h51
ACK
Stop
Start
h68 WR
ACK
h4F
ACK
h0E
ACK
Stop
Start
h68 WR
ACK
h4E
ACK
h52
ACK
Stop
Start
h68 WR
ACK
h51
ACK
h10
ACK
Stop
Start
h68 WR
ACK
h56
ACK
h80
ACK
Stop
Start
h68 WR
ACK
h4F
ACK
h02
ACK
Stop
Start
h68 WR
ACK
h4E
ACK
h4C
ACK
Stop
Start
h68 WR
ACK
h4D
NAK
Stop
Start
ERROR
Start
ERROR
Start
Re-Start
h74 RD
ERROR
Start
h68 WR
NAK
Stop
Start
h68 WR
NAK
Stop
Start
h68 WR
NAK
Stop
06-12-2021 07:59 AM
Any hints on my issue, or can I provide more details ?
Is there a way to debug internal registers of Mag of BMX160 ?
06-16-2021 01:30 AM
Hello Yahya,
Technically, you can write read register for BMX160. That means after writing data you should read proper data from register.
There is information in 2.11 register map datasheet.
As Robin mentioned that, why don't you use our API?
Although you get some data using register level coding, you need to compensate our raw data.
Therefore, our API is much more convenient.
Based on github API, I made example code.
Please let me know if you have any questions.
Thank you.