Due to high demand, expect some shipping delays at this time - orders may not ship for up to 2-3 business days.
0

Broken ICM-20948?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Broken ICM-20948?

by jonrietveld98 on Tue Jan 25, 2022 10:29 pm

I am attempting to interface with the ICM20948 module, but it appears to not be functional. When I request the whoami value (bank 0 register 0) from the chip via spi, I get 0xE0 back instead of 0xEA which I should be seeing according to the datasheet. This is causing the driver provided by invensense to fail out as I believe it should. Is this a faulty module?
Order number: 2716330-2071978699
Product link:
https://www.adafruit.com/product/4554
Datasheet link (see page 36):
https://invensense.tdk.com/wp-content/u ... 8-v1.3.pdf
Code used to read the register:
Code: Select all | TOGGLE FULL SIZE
#include <SPI.h>

void setup()
{
  Serial.begin(115200);
  delay(5000);
  pinMode(10, OUTPUT);
  SPI.begin();



  while (Serial.available() <= 0) {
    Serial.print('A');   // send a capital A
    readwhoami();
    delay(300);
  }
}

void loop()
{
}


int readwhoami(void)
{
  uint8_t reg = 0;
  uint32_t rlen = 1;

  SPI.beginTransaction(SPISettings(7000000, MSBFIRST, SPI_MODE0));
  SPI.transfer(0x00);
  SPI.endTransaction();

  digitalWrite(10, LOW);
  SPI.beginTransaction(SPISettings(7000000, MSBFIRST, SPI_MODE0));
  SPI.transfer(((reg & 0x7F) | 0x80));
  for (uint32_t indi = 0; indi < rlen; indi++)
  {
    Serial.println(SPI.transfer(0x00));
  }
  SPI.endTransaction();
  digitalWrite(10, HIGH);

  return 0;
}
Attachments
IMG-5063.jpg
IMG-5063.jpg (917.31 KiB) Viewed 141 times
IMG-4960.jpg
IMG-4960.jpg (293.42 KiB) Viewed 141 times

jonrietveld98
 
Posts: 4
Joined: Tue Jan 25, 2022 10:13 pm

Re: Broken ICM-20948?

by mikeysklar on Thu Jan 27, 2022 5:28 pm


mikeysklar
 
Posts: 7522
Joined: Mon Aug 01, 2016 8:10 pm

Re: Broken ICM-20948?

by jonrietveld98 on Fri Jan 28, 2022 8:58 pm

I tried that library, and it is able to retrieve gyroscope and accelerometer data, but no magnetometer data. It also appears that the DMP module is not working with the invensense library. Seems like only half the chip is working.
Attachments
broken icm20948.png
broken icm20948.png (41.01 KiB) Viewed 104 times

jonrietveld98
 
Posts: 4
Joined: Tue Jan 25, 2022 10:13 pm

Re: Broken ICM-20948?

by mikeysklar on Mon Jan 31, 2022 4:24 pm

I think you need to set the datarate for the magnetometer. Probably just uncomment this first line from the example code here. Our SPAM keyword is making me comment out the first three characters, but look for this in the Arduino code.

Code: Select all | TOGGLE FULL SIZE
   
// XXX.setMagDataRate(AK09916_MAG_DATARATE_10_HZ);
  Serial.print("Magnetometer data rate set to: ");
  switch (XXX.getMagDataRate()) {
  case AK09916_MAG_DATARATE_SHUTDOWN:
    Serial.println("Shutdown");
    break;

mikeysklar
 
Posts: 7522
Joined: Mon Aug 01, 2016 8:10 pm

Re: Broken ICM-20948?

by jonrietveld98 on Sat Feb 05, 2022 3:20 pm

Unfortunately that did not make a difference. I have attached the file I uploaded to the UNO. Here is what the serial monitor shows:
broken icm20948_2.png
broken icm20948_2.png (34.21 KiB) Viewed 65 times
Attachments
sketch_jan28a.ino
(4.92 KiB) Downloaded 1 time

jonrietveld98
 
Posts: 4
Joined: Tue Jan 25, 2022 10:13 pm

Re: Broken ICM-20948?

by mikeysklar on Mon Feb 07, 2022 5:04 pm

It looks like we have an open issue in the Adafruit_ICM20X github repo on the magnetometer not being accessible via SPI only via I2C.

https://github.com/adafruit/Adafruit_ICM20X/issues/13

Looking in some other forums it looks like it possible to get magnetometer communication in SPI mode, but is much more involved.

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


https://devzone.nordicsemi.com/f/nordic ... eter-issue

mikeysklar
 
Posts: 7522
Joined: Mon Aug 01, 2016 8:10 pm

Re: Broken ICM-20948?

by jonrietveld98 on Mon Feb 07, 2022 11:25 pm

I gave I2C a try and now it appear to be working perfectly. It looks like there is either a HW issue with SPI (with the whoami register not being set) or there is some SW setting that needs to be enabled for the correct value to be returned. Either way, reading through how the ICM20948 library works, now it appears that the whoami value is being returned correctly as I am not seeing an error message on run, and am getting back the magnetometer values.

jonrietveld98
 
Posts: 4
Joined: Tue Jan 25, 2022 10:13 pm

Please be positive and constructive with your questions and comments.