I am working on a major project for rocket telemetry and I've stumbled on a strange conflict between an SD Card (on SPI) and a MPU9250 accelerometer (on I2C). These are both connected to an Arduino Mega 2560 board mounted on a custom shield. There is nothing else on the SPI bus and there is a small BMP180 pressure sensor also on I2C.
In general, everything works perfect, except when I sample the accelerometer from the MPU9250, immediately following an SD Card write to disk. When I sample following a write to disk I occasionally get random garbage from the accelerometer. The code and variables used for each device is completely isolated, so I suspect something much lower level is going on. If I add a 50ms delay after the SD Card write then the MPU is happy and never reports an anomaly. This could be a fix, but on my project, when a rocket launches I need to rapidly capture acceleration and log it to the SD without missing a beat.
The SD Card (http://a.co/j4VBbpv) and the MPU9250 (http://a.co/1jCkbh8) are mounted next to each other on the shield. I even put the SD card on a separate power line and regulator from a LiPo battery to see if that would help (it did not).
My SD logging code opens files on startup, so the "offending" writes that cause the MPU to go crazy don't include file open or file close.
Has anyone heard of an SD write interfering with an accelerometer?