MMA7660 example program

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MMA7660 example program

1,782 Views
venerable13
Contributor I

I need an example program that initializates the accelerometer and read the x, y, z coordenades which are putting in variables and then I will use them on a lcd screen.

 

Thanks, I need it for a fhysics project

Labels (1)
0 Kudos
1 Reply

262 Views
Mickey
Contributor III

The following is processor expert:

 

main.c

 

 error = I2C1_SelectSlave(0x4C);

 buf[0] = 0x07;
 buf[1] = 0x00;
 error = I2C1_SendBlock(buf, 2, &sent);
 while(!TransmitComplete){}
 TransmitComplete = 0;
 error = I2C1_SendStop();

 buf[0] = 0x05;
 buf[1] = 0x00;
 error = I2C1_SendBlock(buf, 2, &sent);
 while(!TransmitComplete){}
 TransmitComplete = 0;
 error = I2C1_SendStop();

 buf[0] = 0x06;
 buf[1] = 0x10;
 error = I2C1_SendBlock(buf, 2, &sent);
 while(!TransmitComplete){}
 TransmitComplete = 0;
 error = I2C1_SendStop();

 buf[0] = 0x09;
 buf[1] = 0xE0;
 error = I2C1_SendBlock(buf, 2, &sent);
 while(!TransmitComplete){}
 TransmitComplete = 0;
 error = I2C1_SendStop();

 buf[0] = 0x08;
 buf[1] = 0x62;
 error = I2C1_SendBlock(buf, 2, &sent);
 while(!TransmitComplete){}
 TransmitComplete = 0;
 error = I2C1_SendStop();

 buf[0] = 0x0A;
 buf[1] = 0x00;
 error = I2C1_SendBlock(buf, 2, &sent);
 while(!TransmitComplete){}
 TransmitComplete = 0;
 error = I2C1_SendStop();

 buf[0] = 0x07;
 buf[1] = 0x41;
 error = I2C1_SendBlock(buf, 2, &sent);
 while(!TransmitComplete){}
 TransmitComplete = 0;
 error = I2C1_SendStop();

 buf[1] = 0;

 for(;;)
 {
  while(Bit1_GetVal());
  TransmitComplete = 0;
  buf[0] = 0;
  error = I2C1_SendBlock(buf, 1, &sent);
  while(!TransmitComplete){}
  error = I2C1_RecvBlock(&data,3,&ret);
  error = I2C1_SendStop();
 }

 

event.c

 

 

void I2C1_OnTransmitData(void)
{
  /* Write your code here ... */
 TransmitComplete = 1;
}

 

 

 

0 Kudos