LittleBrain-STM32F4-Sensorboard icon indicating copy to clipboard operation
LittleBrain-STM32F4-Sensorboard copied to clipboard

SPI NSS for gyro and accelerometer being pulled low at the same time.

Open jisang1213 opened this issue 1 year ago • 0 comments

I've faced an issue with gyro and accelerometer CS pins being pulled low simultaneously, making the retrieved data contain garbage values once a while (about every 1~2 seconds). There needs to be a mechanism to prevent this like using while() to wait for its turn to read.

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
	if (GPIO_Pin == INT_ACC_Pin) {
                while(imu.readingGyr);
                BMI088_ReadAccelerometerDMA(&imu); 

	} else if (GPIO_Pin == INT_GYR_Pin) {
                while(imu.readingAcc);
                BMI088_ReadGyroscopeDMA(&imu);
	}
}

and in the BMI088.c file the imu.readingGyr and imu.readingAcc flags should be set before pulling the CS low (and unset after pulling CS to high) to prevent race condition.

jisang1213 avatar Sep 26 '24 05:09 jisang1213