Hi All!
I am trying to connect an MPU-6050 (ITG-MPU breakout board) with ATmega8 (on a breadboard - non arduino) via I2C.
When I try to read one of the sensor values the TWSR values show perfect I2C communication,
like for example twsr values for: Start, Slave+W, Address ack, Register AddressACK, Slave+R, Data to twdr, nack by master, Stop, etc. all match with atmega8's data-sheet (I connected 8-pins of portD to 8 LEDS and set twsr to display on this port every time a twsr check operation is performed).
But the values I receive in twdr are all constant and does not change by any movements of sensor (I tried displaying the sensed values on an 8-LEDS arrangement and also on an lcd).
I communicate on i2c in following manner:
Send Start,
Check twsr,
Send Slave address with write bit,
Wait for NACK or ACK,
Check TWSR,
Send Sensor register address,
Wait for NACK or ACK,
Check TWSR,
Send START (repeated start)
Check TWSR,
Send Slave address with read,
Wait for NACK or ACK,
Check TWSR,
Copy TWDR data to an element of an Array,
Send "NACK",
Check TWSR
Stop.
I continuously monitor TWINT flag in all steps. And these steps are repeated again and again for different sensor registers.
Also I have enabled interrupt (by including sei ) but I have not put anything in the Interrupt vector.
My Question(s) is :
Why is this data constant?
Is there a problem with my I2C communication approach?
Or is the MPU operating on 3V3 and AVR on 5V killing the sensed data? (I use 4K7 pull-ups to 5V)
Or any other registers are to be configured (I tried PWR_MGMT_1, USER_CTRL, CONFIG, SMPRT_DIV, GYRO_CONFIG, ACCEL_CONFIG in this very order) before actual register addressing and data reading?
Or some other problem?
If similar experience had been discussed before or a discussion that might help, Please redirect.
Thanks.
Pardon my typing.
I am trying to connect an MPU-6050 (ITG-MPU breakout board) with ATmega8 (on a breadboard - non arduino) via I2C.
When I try to read one of the sensor values the TWSR values show perfect I2C communication,
like for example twsr values for: Start, Slave+W, Address ack, Register AddressACK, Slave+R, Data to twdr, nack by master, Stop, etc. all match with atmega8's data-sheet (I connected 8-pins of portD to 8 LEDS and set twsr to display on this port every time a twsr check operation is performed).
But the values I receive in twdr are all constant and does not change by any movements of sensor (I tried displaying the sensed values on an 8-LEDS arrangement and also on an lcd).
I communicate on i2c in following manner:
Send Start,
Check twsr,
Send Slave address with write bit,
Wait for NACK or ACK,
Check TWSR,
Send Sensor register address,
Wait for NACK or ACK,
Check TWSR,
Send START (repeated start)
Check TWSR,
Send Slave address with read,
Wait for NACK or ACK,
Check TWSR,
Copy TWDR data to an element of an Array,
Send "NACK",
Check TWSR
Stop.
I continuously monitor TWINT flag in all steps. And these steps are repeated again and again for different sensor registers.
Also I have enabled interrupt (by including sei ) but I have not put anything in the Interrupt vector.
My Question(s) is :
Why is this data constant?
Is there a problem with my I2C communication approach?
Or is the MPU operating on 3V3 and AVR on 5V killing the sensed data? (I use 4K7 pull-ups to 5V)
Or any other registers are to be configured (I tried PWR_MGMT_1, USER_CTRL, CONFIG, SMPRT_DIV, GYRO_CONFIG, ACCEL_CONFIG in this very order) before actual register addressing and data reading?
Or some other problem?
If similar experience had been discussed before or a discussion that might help, Please redirect.
Thanks.
Pardon my typing.
Last edited: