Hi,
I was wondering if anyone could have a look at this problem. It is not a question about using an MUP9250 directly, but the weirdest thing I ever found whilst I went through the learning curve on my lonesome.
For info, I using a window 7 Ultimate machine. A photon, connected to an MPU9250 clone via i2c to experiment with motion detection.
Basically I’ve written a load of code which initially sets up the MPU9250 for Accel and Gyro, and accesses in Mag (AK8963).
There are tonne of register reads for debugging. Finally there are 3 subroutines which individually in turn read the accelerommeter, gyro, and mag data in turn, do some math and print the results. The delay before the subroutines call controls the speed of the output to a serial output.
As I was doing the learing, I found that for some reason when I was doing the read of the Mag data, without performing a complete register read, my computer would go absolutely mental. The mouse would bounce around all over the place I had no control, unless I unplugged the photon, and used Alt-Control-Del, then waited untill the mouse stopped jumping around and selected cancel to get back to the desk top. I could reflash the photon by using a USB psu, so the photon didn’t crash, or freeze up…itself. The speed of the demonic mouse action was related to the speed of the main loop.
After about 4 days of bashing my head against the ‘try-this, then-that’ approch of de-bugging I discovered that a tleast 2 out of three serial.print statements were to blame. If I '//'ed them out the code would run fine, if I leave them in, all hell broke loose. The code has loads of print statements, I’ve added others in, taken others away, but these three lines are causing the problem. And they have taken DAYS to track down as the casue. I thought it would be due to a variable type mis match or maths error, but trust me all I have to do is // these Serial.println() statements and everything is as expected. And it is a repeatable problem…
Has anyone experianced this before.
As it some 700 lines of code I will spare you just pasting it in, and I can not remember how to insert a code block in to this message system. None of the icons at the top of this message window look like they are the right ones. If your interested and can help then I will post the code upon request. I tried to uplad a txt file but that only allows pictures…
Thanks for thoughts.
Liam