I am using a MPU9250. If I get the values from polling they are ok, If I get them from an interrupt they are all wrong. Why?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi Cypress community.

I'm making a little robot that will use a MPU9250 for balance purposes, the brain of the robot is a CY8CKIT-059.

They communicate by using SPI, the PSoC being the master and the MPU9250 the slave.

I made some functions to write and read registers on the MPU9250, and they work fine, but only if I call them from the main infinite loop.

I put a timer to dictate the sampling rate of the system, and I am using the terminal count interruption to call the functions in the correct amount of time.

The problem is that the values of the accelerometers (x, y and z), and gyroscopes (planes xy, xz and yz), are all wrong, like all over the place, if they are read from the interrupt, but are totally OK if they are read from the infinite loop.

What would be the cause or a possible solution?

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Quite difficult to guess the cause.

Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes
Anonymous
Not applicable

Thanks for the reply Bob, I will do it later today, but I found a workaround, instead of executing the functions call from the interrupt, I raise a flag and execute them from the main loop.

0 Likes