Hi
I'm trying to read the magnetometer from the ICM-20948. I'm using the SPI interface.
I can't get data. I've tried a lot of combinations of code, but none seems to work.
I do communicate with the acc and gyro, so communication seems to be ok.
Any ideas why the following code does not work?
icm_set_bank(0);
printf("WHOAMI:0x%02X\r\n",R_CONFIG(WHO_AM_I)); //Replies as it should.
W_CONFIG(PWR_MGMT_1, 0b10000000); //Reset CHIP
delay_ms(50);
W_CONFIG(PWR_MGMT_1, 0b00000010); //Clock sel 2
W_CONFIG(INT_PIN_CFG, 0b00000000); //Bypass enabled if bit 1 is set.
W_CONFIG(USER_CTRL, 0b00100000); //I2C Master mode
icm_set_bank(3);
W_CONFIG(I2C_SLV0_ADDR, 0b10001100); //Set the I2C slave address and set for read.
delay_ms(10);
W_CONFIG(I2C_SLV0_REG, 0x01); //I2C slave register address from where to begin data transfer
delay_ms(10);
W_CONFIG(I2C_SLV0_CTRL, 0x81); //Read 1 bytes from the magnetometer
delay_ms(100);
icm_set_bank(0);
printf("0x%02X\r\n",R_CONFIG(EXT_SLV_SENS_DATA_00));