This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

magnetometer on spi

i am using mpu 9250 and and using https://github.com/Martinsbl/nrf5-mpu-examples this examples.

the question is can i use magnetometer on spi protocol?

because i have not found any code on spi?

Parents
  • 1. Write to the USER_CTRL register, setting I2C_MST_EN

    2. Write to I2C_MST_CTRL, setting the bus speed 400KHz and to stop between read

    3. Write to I2C_MST_DELAY_CTRL, enabling delay odr for the slave you wish the mag to be represented by(the following instructions will assume 0.

    4. Write to I2C_SLV0_ADDR to write mode, and slave address to the magnetometer (0x0C)

    5. Write to I2C_SLV0_REG, setting the address to be written as the address of CTRL2 in the magnetometer

    6. Populate ICM20948_I2C_SLV0_DO with the desired control setting

    7. Write to ICM20948_I2C_SLV0_CTRL,  enabling the mag and setting the grouping and bytes to be read

    8. Switch I2C_SLV0_ADDR to read mode and I2C_SLV0_REG to HXL

    9. EXT_SLV_SENS_DATA_(00 to 06) will now be populated with HXL to ST2. It should be noted that reading ST2 is necessary as this automatically triggers the data to update in the axis registers.

    10. Additionally, FIFO_EN_1 can be set to write slv(magnetometer) data to the FIFO

Reply
  • 1. Write to the USER_CTRL register, setting I2C_MST_EN

    2. Write to I2C_MST_CTRL, setting the bus speed 400KHz and to stop between read

    3. Write to I2C_MST_DELAY_CTRL, enabling delay odr for the slave you wish the mag to be represented by(the following instructions will assume 0.

    4. Write to I2C_SLV0_ADDR to write mode, and slave address to the magnetometer (0x0C)

    5. Write to I2C_SLV0_REG, setting the address to be written as the address of CTRL2 in the magnetometer

    6. Populate ICM20948_I2C_SLV0_DO with the desired control setting

    7. Write to ICM20948_I2C_SLV0_CTRL,  enabling the mag and setting the grouping and bytes to be read

    8. Switch I2C_SLV0_ADDR to read mode and I2C_SLV0_REG to HXL

    9. EXT_SLV_SENS_DATA_(00 to 06) will now be populated with HXL to ST2. It should be noted that reading ST2 is necessary as this automatically triggers the data to update in the axis registers.

    10. Additionally, FIFO_EN_1 can be set to write slv(magnetometer) data to the FIFO

Children
No Data
Related