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
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; }