Using LIS25BA with STM32L4 Nucleo Board
I am using STM32L452RE Nucleo Board and LIS25BA module.
I2C works fine. I wish to get accelerometer data through TDM now. I am unable to do so. For now, I am using polling mode. The code I am using is given below and the SAI configuration I am using is also attached.
/* USER CODE BEGIN 2 */
int16_t rdat[8];
uint8_t chipid=0;
uint8_t cmax=0x7f;
uint8_t ctrlreg=0;
uint8_t tdmctrlreg=0x64;
uint8_t axesctrlreg=0xe0;
uint8_t rcmax;
uint8_t rctrlreg;
uint8_t rtdmctrlreg;
uint8_t raxesctrlreg;
HAL_I2C_Mem_Read (&hi2c2, 0x33, 0x0f, 1, &chipid, 1, 100);
HAL_I2C_Mem_Write(&hi2c2, 0x32, 0x25, 1, &cmax, 1, 100);
HAL_I2C_Mem_Write(&hi2c2, 0x32, 0x26, 1, &ctrlreg, 1, 100);
HAL_I2C_Mem_Write(&hi2c2, 0x32, 0x2e, 1, &tdmctrlreg, 1, 100);
HAL_I2C_Mem_Write(&hi2c2, 0x32, 0x2f, 1, &axesctrlreg, 1, 100);
HAL_I2C_Mem_Read (&hi2c2, 0x33, 0x25, 1, &rcmax, 1, 100);//read data back
HAL_I2C_Mem_Read (&hi2c2, 0x33, 0x26, 1, &rctrlreg, 1, 100);//read data back
HAL_I2C_Mem_Read (&hi2c2, 0x33, 0x2e, 1, &rtdmctrlreg, 1, 100);//read data back
HAL_I2C_Mem_Read (&hi2c2, 0x33, 0x2f, 1, &raxesctrlreg, 1, 100);//read data back
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_SAI_Receive(&hsai_BlockA1, (uint8_t*)rdat, 8, 100);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
Please let me know if it is possible to get data using SAI or I2S or any other method using this nucleo board or any other board. Thanks.
