AnsweredAssumed Answered

MMA7660FC Programming

Question asked by Tom Ruby on Dec 21, 2012

Must have something wrong here as any register I read from my MMA7660FC contains 255.

 

I'm using AVR processors, 'cause that's what I know, and Peter Fluery's vaunted I2c library. This is my first try at using I2C. It seems pretty nice, if I can make it work

 

If I try to start with the wrong slave address, I get no response. If I use the correct slave address, 0x4C << 1, I do get a response, so I suspect my test board is working.

 

So, in setting up my MMA7660FC, I first:

 

WriteMMA(MMA_SR,7); // 1 sample per second, no filter.

WriteMMA(MMA_INTSU,1); // Back/Front interrupt (which isn't hooked up)

 

My writeMMA method is:

void WriteMMA(uint8_t R, uint8_t V) // Write v into register R

{

i2c_start_wait(MMA+I2C_WRITE); // set device address and write mode

i2c_write(R); // Register to write

i2c_write(V); // Value to write

i2c_stop();

}

 

Then, I loop, reading the tilt register and displaying it whenever it changes.

 

while(1)

  {

uint8_t X = ReadMMA(MMA_TILT) ; // Read the x register

if (oX != X)

{

oX = X;

j += 1;

LCDclear();

ShowByte(j);

LCDxy(0,1);

ShowByte(X);

}

  }

 

(Do you have [CODE] tags here?)

 

And, the ReadMMA method always gets me 255.

 

I've attached the source of the actual program.

 

 

I know the program is lame, but I generally don't write a complicated program doing something I don't know anything about until I've made something simple that I don't know anything about work.

 

Have I missed something in the setup?

Perhaps I'm misusing ack and nak while reading?

Perhaps my program is correct and my little test board is wonky?

 

(This is the second time I've tried soldering one of these "QFN" type things without any pins. I don't want to talk about the first try )

Original Attachment has been moved to: Torby.zip

Outcomes