MPU9250 1khz sample to sd card teensy 3.6

Status
Not open for further replies.

morgan.s

New member
hello! i am super new to the whole arduino ide in general. i have some embedded experience via classes i have taken, but it is limited when applied to the hardware i am working with.

in short: i am using a teensy 3.6 with an MPU9250 sparkfun breakout. i have attached a picture of the schematic that i am using as the setup. the picture is a crude teensy (with pin #s) and mpu in lt spice (should just be picture format). my goal is to acquire 1k samples/second (1kHz sample freq) and write it to a file on an sd card. i am aware that sd cards take quite a bit of time to open a file. to circumvent this i have attempted to use a ping pong buffer (probably crudely implemented) to write ~1k points, then dump the buffer onto the file on the sd card while simultaneously writing to the second buffer. somewhere in the program, the entire program hangs. i have used an oscilloscope and seen that when attempting to flip the GPIO pins, the pins stay high in the interrupt routine, and in the body of the main loop. i am quite perplexed and ANY help is appreciated! keep in mind i am not super well versed so any response will probably merit several follow up questions! thanks again! also, sorry for the lengthy post, simply wanted to detail all the issues as well as i could.

p.s. want to give a shout out to the person who wrote the code i have since been editing. unfortunately i did not get a name with the code and any documentation or trace has been lost (have not touched the code in a couple of semesters), BUT should you stumble upon this article, THANK YOU so much for the help thus far!
 

Attachments

  • Int-test_pingpong.ino
    18.4 KB · Views: 76
  • circuitpic.PNG
    circuitpic.PNG
    18.4 KB · Views: 117
There is a lot of code there, more than I really care to go through but a few things that jump out:

You have no protection from writing data to a buffer after it is full. This will clobber whatever happens to be there.

I can't find where you write to register 55 which means that you must read the interrupt status register (58) to clear the MPU9250 interrupt status. Just start there when reading the data rather than making a special thing of it.

SD cards work best when data is written in multiples of 512 bytes. Use 32KB buffers.

You never check the result from the MPU9250 initialization so you don't know if that even worked.

The usual way to handle all of those constants is via #define. This lets the compiler know what value to use without using any space on the target.
 
Status
Not open for further replies.
Back
Top