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

ICM20948 magnetometer issue

Hi,

I am develloping product witch ICM20948 and need to use magnetometer. I tried to move some existing and working code for arduino. I was able to get data from magnetometer. But next day when i tried the same thing, magnetometer wasnt responding. Just sometimes it ran for a while. In datasheet I founded that reseting i2c master is possible, but after this reset it was working 50/50. Sometimes yes, sometimes not. Now it isnt working at all. I know that it has not much in common with Nordic but I completely ran out of ideas. Please, could someone help me? I thing the problem is in the i2c master, but now also resseting it doesnt work. I could try post this issue to Stackoverflow, but they immediatelly mark this question as non related to programming, so I am asking you. 

Regards

Parents
  • Hi, I know this as asked a while ago, but there is still very little information on how to get the icm20948 magnetometer working in SPI mode. So thought I'd write this to clarify. The magnetometer can be written to and read from in SPI mode. The sequence for this is as follows.

    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
  • Hi, I know this as asked a while ago, but there is still very little information on how to get the icm20948 magnetometer working in SPI mode. So thought I'd write this to clarify. The magnetometer can be written to and read from in SPI mode. The sequence for this is as follows.

    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
Related