tretra
Newbie level 1
- Joined
- Jun 21, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 8
I'm trying to interface the freescale mma7660 accelerometer with an 8051 processor (c8051f020 silicon labs).
I get some problems while I communicate with the smbus:
I receive acks from the accelerometer, but the data I get is always 0.
This is my initialization code (for the accelerometer):
And this is my read function:
I'm quite sure my smbus initialization is correct because I use the i2c protocol with other components without getting any problem.
This is the datasheet
Did I do something wrong? Any help would be greatly appreciated
Thanks
I get some problems while I communicate with the smbus:
I receive acks from the accelerometer, but the data I get is always 0.
This is my initialization code (for the accelerometer):
Code:
SMB_DATA_IN[0] = 0x07; //stand by mode
SMB_DATA_IN[1] = 0x00;
SMB_Write(); //write data on the smbus
delay1ms(100);
SMB_DATA_IN[0] = 0x06; //auto interrupt
SMB_DATA_IN[1] = 0x10;
SMB_Write();
delay1ms(100);
SMB_DATA_IN[0] = 0x08; //auto wake up
SMB_DATA_IN[1] = 0x00;
SMB_Write();
delay1ms(100);
SMB_DATA_IN[0] = 0x07; //active mode
SMB_DATA_IN[1] = 0x01;
SMB_Write();
delay1ms(100);
And this is my read function:
Code:
void readData() {
SMB_DATA_IN[0] = 0x00;//X value
SMB_Write();
delay1ms(100);
SMB_Read(); //reads data and put everything in an array
}
I'm quite sure my smbus initialization is correct because I use the i2c protocol with other components without getting any problem.
This is the datasheet
Did I do something wrong? Any help would be greatly appreciated
Thanks