2
\$\begingroup\$

On the MMA7455 accelerometer, there is only one DATA pin which is used for both input and output. On the manual, it tells me to connect this pin to SDI and SDO. Now that's all fine, but on my chip, these are two separate pins.

If I connect SDI and SDO pins to the DATA pin, won't the data that flows out of SDO go into the SDI pin as well? Wouldn't this cause any problems?

Is there are any buffering that would potentially store the data the comes in through SDI? (So maybe after sending something out of SDO, I can clear the buffer at SDI to avoid reading what I just sent).

enter image description here

\$\endgroup\$

2 Answers 2

5
\$\begingroup\$

Based on the picture, it seems you have a breakout board/module for the MMA7455, by Parallex? The chip itself allows for both 4 wire and 3 wire spi, but that module only has the 3 wire mode enabled.

But that's not really a problem. The thing about 3 wire mode is that it is half duplex, only transmits one way at a time. And this device is a slave device, it does not send arbitrary data at all times. By hooking up sdi and sdo to the same pin, you just have release the sdo pin (tristate/input mode) when you expect to read data. You Control the Clock so you control when and how fast the accelerometer sends data. You assert the cs pin, you send the register address with the read bit, then before you start clocking in the data, you release the SDO pin. You clear your buffer, then you clock the data in. If you're not ready, don't tick the spi clock.

What you want/need to do is also take a look at the chip's datasheet, not just the module's datasheet.

\$\endgroup\$
1
\$\begingroup\$

With this kind of chip, there is not much advantage to using the built-in SPI peripheral of the microcontroller. Just connect the accelerometer to some general-purpose IO pins and write software to make the waveforms shown in the datasheet's timing diagram. Bit-bang style!

Or use I2C mode instead.

\$\endgroup\$
1
  • \$\begingroup\$ It's true that an accelerometer is not apt to produce so much data that the ~4x slowdown from using bit-bang I/O would pose a problem, and the suggestion of using bit-bang I/O is a good one. It's worth noting, however, that the question is just as applicable to some other devices which may supply or consume enough data to make performance an issue. \$\endgroup\$
    – supercat
    Commented Jan 4, 2013 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.