I2C fail in case of UART interrupt?
Hello everyone!
I'm asking for your help with the following: I have a board equipped with an STM32L151 processor, with which I use an STM32 ISM330DHCX IMU via I2C. The ODR is set to 52Hz for both the gyroscope and the accelerometer, and I request an accelerometer interrupt on the INT1 pin. In the interrupt handler, I simply set a (volatile) boolean value to true, and in the main loop, I read out the sensor values. Meanwhile, messages arrive via UART at a frequency of 20Hz, to which I respond with a slight delay in milliseconds. Both UART RX and TX are set to DMA mode. In certain cases, the I2C communication fails, and I suspect that this is because while the I2C communication is in progress, a UART (or DMA) interrupt interrupts it. This is visible on the oscilloscope as well: yellow is UART communication (RS485 in this case), pink indicates data retrieval function call in the main loop, and blue is the I2C SDA pin.
What would be the appropriate procedure? Initially, it occurs to me that I should disable the UART interrupt while the I2C communication is taking place, but that doesn't seem like an elegant solution.
P.S. I stopped the UART communication, and the issue has become less frequent, but it has not been resolved...


