Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

mpu 6050 problem for atmega 8

Status
Not open for further replies.

Disha Karnataki

Full Member level 5
Full Member level 5
Joined
Jul 20, 2013
Messages
249
Helped
9
Reputation
18
Reaction score
8
Trophy points
18
Location
india
Visit site
Activity points
2,231
i have rigged up this sensor to my atmega 8 microcontroller :
here is the image of sensor:http://playground.arduino.cc/uploads/Main/mpu-6050.jpg
i have given 3v supply to the board. And i am using pleury's header file for i2c communication b/w my sensor & atmega. so below i have written a code to see just whether the device is accessible or not
pin connections to mpu:
vcc-3v
scl,sda pins of mpu: i have connected 4.7k pulls ups through 3v supply as per the dig here;
http://blog.codeblack.nl/image.axd?picture=2011/7/Netduino.I2C.png and have given it to scl (pc5) &sda (pc4) pins of atmega.
xcl,xda pins are left open.
ad0 pin is given to 0v.
int pin open.
as per datasheet if ad0=0 then address of the device =0X68.

i am using avr studio 4.

here is my code:
Code:
#include<avr/io.h>		         //This is the header for AVR Microcontroller.
#define F_CPU 12000000UL
#include "i2cmaster.h"
#include<util/delay.h>      
#include"lcd118010.h"	              //lcd 
#define mpu 0X68                     //address of the i2c device
int main(void)
{
unsigned char ret=0;
PORTC=0X00;                           //disabling the internal pull up for sda,scl
lcd_init();
i2c_init();                                   //initialise i2c communication

while(1)
{
lcd_string("hi ");
_delay_ms(1000);

ret=i2c_rep_start(mpu);      //send adress to recognize slave device  and if  ret=0 device is  accesible  ret=1 device is not accessible 

lcd_showvalue(ret);  //print that value on lcd 
_delay_ms(1900); 

lcd_clear();    //clear lcd & continue
}
}

my observations :lcd is printing "hi" but, ret value is not printing(neither 1 nor 0) and neither is lcd clearing. but if i am commenting
Code:
ret=i2c_rep_start(mpu);
then only lcd clears & rexecutes the loop

how do i solve this problem? is my sensor ok?
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top