cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing stm32h with ICM42670 using I2C

sid1401w
Associate

I want my accelerometer to read data within the range of 4g . i don't know where i'm getting wrong .

 

2 REPLIES 2
padawan
Senior

Hi sid,

at frist :

have you put in the pullups (maybe 3k3) at SDL and SCL?

Is the pin 12(AP_CS) pulled to VDDIO? This tells the device to go into I2C mode..

Is the pin 1 ( APD_ADO) on VDDIO or GND? If GND the address is 0x68<<1 (0xD0).

If it is connected to VDDIO then its your address 0x69<<1(0xD2)

Then try to get the "WHO_AMI_I" so you are save that the device is talking with you.

here an untestet code snip. if you debug this you can see at the _hal the returncode of the HAL_I2C

function.

 

uint8_t Get_ID()
{
	HAL_StatusTypeDef _hal;
	I2C_HandleTypeDef* _i2c = &hi2c4;
	uint8-t adr = 0x68<<1; // 0xD0
	uint8_t _smbuff[1] ;
			_smbuff[0]= 0x75 ; // WHO_AM_I
	uint8_t _rmbuff[1];		
	
	_hal = HAL_I2C_Master_Transmit (_i2c, _adr, _smbuff, 1 ,100);
	
	_hal = (HAL_I2C_Master_Receive(_i2c,_adr, _rmbuff, 1,100)); // read
	if (_hal == HAL_OK)
	{
		return _rmbuff[0]; // Who_am_i = 0x67
	}
	else
	{
		return _hal;
	}	
}

 

   HTH

Padawan

 

 

 

padawan
Senior

Hi Sid

is your problem solved?

yust asking

Padawan