MMA7660 sample code?
VonSzarvas
Posts: 3,617
Anyone got the MMA7660 sensor working with the Propeller ?
Looking for some sample code... can be SPIN, PASM, PropBasic!, or even SX/B or some other B-Stamp format. I would be converting to PropBasic, so will publish the code back here when working unless someone has beaten me to it?
Thanks for any help.
Looking for some sample code... can be SPIN, PASM, PropBasic!, or even SX/B or some other B-Stamp format. I would be converting to PropBasic, so will publish the code back here when working unless someone has beaten me to it?
Thanks for any help.

Comments
hex \ MMA7660 Accelerometer code \ Using Propforth 4.6 : @I2C \ ( device -- ) \ Select device i2cstart i2cwrite drop ; : @ACC \ ( reg -- ) Select Register 98 @I2C i2cwrite drop ; : ACC! \ ( data reg -- ) Write Register @ACC i2cwrite drop i2cstop ; : ACC@ \ ( reg -- dat ) Read Register @ACC 99 @I2C 1 i2cread i2cstop ; : XYZ@ \ ( -- long ) Read first four registers as a long 0 @ACC 99 @I2C 0 i2cread 0 i2cread 0 i2cread 1 i2cread i2cstop 18 lshift swap 10 lshift + swap 8 lshift + + ; : !ACC \ Init the Accelerometer i2cstop 0 7 ACC! 0 5 ACC! 10 6 ACC! 34 8 ACC! e0 9 ACC! 62 8 ACC! 0 A ACC! 41 7 ACC! ; \ List the accelerometer registers : SHOW 0 @ACC 99 @I2C hex 0b 0 do i 0a = i2cread .byte 20 emit loop i2cstop ;Have it solved now.. Very nice to see the readings for shake and orientation working correctly! I will experiment a bit more with making sense of the acceleration data (as I wish to provide a record of movement along a plane, and I think that would also be useful for others), then I will clean up and post the code.