Discussion in "8051 Discussion Forum" started by    bobby    Jul 27, 2010.
Tue Jul 27 2010, 05:22 pm
#1
hello,

I'm having problem to impliment i2c for mma7660 to interfacie with AT89s52.
i have interfaced ds1307 to AT89s52.same i2c code is not working for this.
please help me.
Tue Jul 27 2010, 10:50 pm
#2
are you guys from some training institute or something? coz everyone is coming up with same problem.

check your code you must be doing something wrong. even a slight bit error can make a lot of difference in I2C.

You can make use of code given in website for help.
Wed Jul 28 2010, 11:55 am
#3


are you guys from some training institute or something? coz everyone is coming up with same problem.

check your code you must be doing something wrong. even a slight bit error can make a lot of difference in I2C.

You can make use of code given in website for help.

Ajay Bhargav




of course every one will come up with same problem because the first link given by google is to this website if we search for "mma7600 and 8051" in google, and no other forum site discussing on mma7660.


Wed Jul 28 2010, 12:11 pm
#4


hello,

I'm having problem to impliment i2c for mma7660 to interfacie with AT89s52.
i have interfaced ds1307 to AT89s52.same i2c code is not working for this.
please help me.

bobby.sweet75



it will be better if u write ur code here.
Wed Jul 28 2010, 04:25 pm
#5
bobby's code, merged for another multiple post:

hi,
I am posting my code here.is there anything wrong with this

# define	MMA7660_ID 			0x4C	
# define 	XOUT				0x00
# define 	YOUT				0x01
# define 	ZOUT				0x02
# define 	TILT				0x03
# define 	SRST				0x04
# define 	SPCNT				0x05
# define 	INTSU				0x06
# define 	MODE				0x07
# define 	SR					0x08
# define 	PDET				0x09
# define 	PD					0x0A
#define FSL_MMA_AddW 0x98          //MMA7660 Address for Writing
#define FSL_MMA_AddR 0x99          //MMA7660 Address for Reading
#define FSL_MMA_StartAddress 0x00  //MMA7660 g-value registers' start address


void MMA7660_Write(unsigned char ucAddr,unsigned char ucData)
{
	
	I2cStart(); 
	I2cWrite(MMA7660_ID);
	if (IIC_ChkAck()) 
	{                                 
	   	#ifdef ACC_DEBUG
			Lcd_Clear();
			LcdGotoXy(0,0);	                                
			Lcd_Print("WR Address Error");   
		#endif
			I2cStop();	                                      
		return;                                          
	}

	I2cWrite(ucAddr);
	if (IIC_ChkAck()) 
	{                                 
	   	#ifdef ACC_DEBUG
			Lcd_Clear();
			LcdGotoXy(0,0);	                                
			Lcd_Print("Sensor Reg NACK");   
			
		#endif
			I2cStop();	                                      
		return;                                          
	}
    I2cWrite(ucData);
	if (IIC_ChkAck()) 
	{                                 
	   	#ifdef ACC_DEBUG
			Lcd_Clear();
			LcdGotoXy(0,0);	                                
			Lcd_Print("Sensor Data NACK");   
			
		#endif
			I2cStop();	                                      
		return;                                          
	}
	I2cStop();       
}
unsigned char MMA7660_Read(unsigned char ucAddr)
{
	unsigned char ucData;
	I2cStart(); 
	I2cWrite(MMA7660_ID);
	if((IIC_ChkAck())==0) 
	{                                 

			Lcd_Clear();
			LcdGotoXy(0,0);	                                
			Lcd_Print("WR Address Error");   
			I2cStop();	                                                                              
	}

	I2cWrite(ucAddr);
	if((IIC_ChkAck())==0)  
	{                                 
	   	
			Lcd_Clear();
			LcdGotoXy(0,0);	                                
			Lcd_Print("Sensor Reg NACK");   
			I2cStop();	                                                                               
	}
	I2cRepeatStart();
	I2cWrite(MMA7660_ID+1);
	if (IIC_ChkAck()) 
	{                                 
	   	#ifdef ACC_DEBUG
			Lcd_Clear();
			LcdGotoXy(0,0);	                                
			Lcd_Print("RD Address Error");   
		#endif
			I2cStop();	                                      
		return 0;                                          
	}
    ucData=IIC_ReadByteNCK();
	               
   	#ifdef ACC_DEBUG
		Lcd_Clear();
		LcdGotoXy(0,0);	                                
		Lcd_Print("Read Success");   			
	#endif
	I2cStop();	                                                                              
	
     
	return ucData; 
}
void MMA7660_Init(void)
{
	
	MMA7660_Write(MODE,0x00);
	MMA7660_Write(SPCNT,0x00);
	MMA7660_Write(INTSU,0x03);
	MMA7660_Write(PDET,0xE0);
	MMA7660_Write(SR,0x34);
	
	MMA7660_Write(PD,0x00);
	MMA7660_Write(MODE,0x41);
}

bobby.sweet75



@bobby.sweet75, DO NOT CREATE MULTIPLE THREADS for your problems. use the QUICK REPLY form provided at the end of post or use POST REPLY button to reply to a post.

of course every one will come up with same problem because the first link given by google is to this website if we search for "mma7600 and 8051" in google, and no other forum site discussing on mma7660.

rohit.astronaut


the reason i said that is coz all people asking these queries are from hydrabad coz of which i thought that. so case is either you people are from same batch or institutes or your companies are working on a similar kind of projects


[ Edited Wed Jul 28 2010, 04:25 pm ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am