cancel
Showing results for 
Search instead for 
Did you mean: 

ASM330LHHX stops transmitting after some time.

MAnto.2
Associate II

I am using Nucleo F767ZI with SPI interface to ASM330LHHX sensor.

I am using example code from https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/asm330lhhx_STdC/examples/asm330lhhx_read_data_polling.c

After a couple of seconds "asm330lhhx_xl_flag_data_ready_get" allways returns 0.

After power off and power on I get a couple of readings but then again nothing.

What am I doing wrong?

/* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART3_UART_Init();
  MX_SPI4_Init();
  /* USER CODE BEGIN 2 */
 
  platform_init();
  platform_delay(BOOT_TIME);
 
  do{
  	asm330lhhx_device_id_get(&dev_ctx, &whoamI);
  	HAL_Delay(1);
  }while(whoamI != ASM330LHHX_ID);
 
  /* Restore default configuration */
  asm330lhhx_reset_set(&dev_ctx, PROPERTY_ENABLE);
  do {
    asm330lhhx_reset_get(&dev_ctx, &rst);
  } while (rst);
 
  /* Disable I3C interface */
  asm330lhhx_i3c_disable_set(&dev_ctx, ASM330LHHX_I3C_DISABLE);
   asm330lhhx_i2c_interface_set(&dev_ctx, ASM330LHHX_I2C_DISABLE);
   /* Enable Block Data Update */
   asm330lhhx_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
   /* Set Output Data Rate */
   asm330lhhx_xl_data_rate_set(&dev_ctx, ASM330LHHX_XL_ODR_833Hz);
   asm330lhhx_gy_data_rate_set(&dev_ctx, ASM330LHHX_GY_ODR_833Hz);
   /* Set full scale */
   asm330lhhx_xl_full_scale_set(&dev_ctx, ASM330LHHX_2g);
   asm330lhhx_gy_full_scale_set(&dev_ctx, ASM330LHHX_2000dps);
 
   asm330lhhx_xl_hp_path_on_out_set(&dev_ctx, ASM330LHHX_LP_ODR_DIV_100);
   asm330lhhx_xl_filter_lp2_set(&dev_ctx, PROPERTY_ENABLE);
 
  /* USER CODE END 2 */
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
 
	  uint8_t reg;
 
	  /* Read output only if new xl value is available */
	  asm330lhhx_xl_flag_data_ready_get(&dev_ctx, &reg);
	  if (reg)
	  {
		/* Read acceleration field data */
		memset(data_raw_acceleration, 0x00, 3 * sizeof(int16_t));
		asm330lhhx_acceleration_raw_get(&dev_ctx, data_raw_acceleration);
		acceleration_mg[0] = asm330lhhx_from_fs2g_to_mg(data_raw_acceleration[0]);
		acceleration_mg[1] = asm330lhhx_from_fs2g_to_mg(data_raw_acceleration[1]);
		acceleration_mg[2] = asm330lhhx_from_fs2g_to_mg(data_raw_acceleration[2]);
 
		HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
	  }
 
	    asm330lhhx_gy_flag_data_ready_get(&dev_ctx, &reg);
	    if (reg)
	    {
	      /* Read angular rate field data */
	      memset(data_raw_angular_rate, 0x00, 3 * sizeof(int16_t));
	      asm330lhhx_angular_rate_raw_get(&dev_ctx, data_raw_angular_rate);
	      angular_rate_mdps[0] =asm330lhhx_from_fs2000dps_to_mdps(data_raw_angular_rate[0]);
	      angular_rate_mdps[1] =
	        asm330lhhx_from_fs2000dps_to_mdps(data_raw_angular_rate[1]);
	      angular_rate_mdps[2] =
	        asm330lhhx_from_fs2000dps_to_mdps(data_raw_angular_rate[2]);
	      HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
	    }
 
	    asm330lhhx_temp_flag_data_ready_get(&dev_ctx, &reg);
	    if (reg)
	    {
	      /* Read temperature data */
	      memset(&data_raw_temperature, 0x00, sizeof(int16_t));
	      asm330lhhx_temperature_raw_get(&dev_ctx, &data_raw_temperature);
	      temperature_degC = asm330lhhx_from_lsb_to_celsius(data_raw_temperature);
 
	    }
	  HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);
	  HAL_Delay(100);
  }

2 REPLIES 2
Federica Bossi
ST Employee

Hi @MAnto.2​ ,

Are you confident about the stability of Vdd and Vddio?

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
dlb
Associate II

Hi,

I have the same problem. Do you find a solution ?

Thanks in advance for your help...