CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problems with accelerometer MMA7455L

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nOgUkO
Guest







Problems with accelerometer MMA7455L
PostPosted: Tue Apr 28, 2009 2:59 am     Reply with quote

Hi Guys!

I´m using the accelerometer of freescale MMA7455L via I2C.
The microcontroller that i´m using is the PIC18LF4553 runing at 3.3V

I have some problems when i try reading the registers 0x06 0x07 0x08 (8 bit value of x y and z axis); the data displayed in my LCD varies constantly: sometimes read 245, 231, 255, 1, 0, 10, 7... random values

There is the code:

Code:


#include <18F4553.h>
#fusesXTPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,PLL1,CPUDIV1,USBDV,NOVREGEN

#use delay(clock=48000000)
#define USB_CON_SENSE_PIN PIN_C0
#include <usb_cdc.h>
#include <lcd.c>
#use i2c(master,slow,sda=PIN_B0, scl=PIN_B1,FORCE_HW)
 
int data=0;




void main() {
delay_ms(100);
lcd_init();


i2c_start();
i2c_write(0x3A); //0x1D shifted in with a 0 had been 0x3A
i2c_write(0x16); //MODE CONTROL REGISTER
i2c_write(0x05); //CONTINOUS MEASUREMENT
i2c_stop();
delay_ms(30); 


loop:
i2c_start();
i2c_write(0x3A);
i2c_write(0x08); //8 bits output value Z
i2c_start();
i2c_write(0x3B); //0x1D shifted in with a 1 had been 0x3B
data=i2c_read(0);
i2c_stop();
delay_ms(500);
printf(lcd_putc,"\f %u",data);//PRINT DATA INTO LCD

goto loop;
 
}




Someting is wrong in my code?

Please help me!

Thanks! Wink
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Apr 28, 2009 3:48 am     Reply with quote

If readback of configuration registers is correct (constant), it's most likely sensor noise. The values you gave, are at least in an allowed range for zero readings.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group