Hello
Im working on RM G146 module for a month in AVR this module have 2 IC one LSM303DLH and The other one MPU-3050 at fist i want to initialize and enable the LSM303DLH and i create this topic for your help i need help in working with LSM303DLH please help
my self board specifics :
ATMEGA32
crystal (external 16Mhz)
LCD 16*2
.
LSM303DLH datasheet link:
http://www.google.com/url?sa=t&rct=j&q=LSM303DLH&source=web&cd=1&ved=0CCkQFjAA&url=http%3A%2F%2Fwww.x-io.co.uk%2Fres%2Fdoc%2Flsm303dlh.pdf&ei=sL9IT77cAa3P4QTG69WmDg&usg=AFQjCNFKmZvW9eHht-7T81jPhJlU7RedaQ&cad=rja
i write you what i see in my project when i use several source code:
1)this is my circuit on board image:
i write this code to that and it work well and you can see i can measure X axes on lcd(in decimal).
source code:
main(){
i2c_start();
i2c_write(0x30); //acc write adress
i2c_write(0x20); //reg1_a
i2c_write(0x27);
i2c_start();
i2c_write(0x30);
i2c_write(0x23);
i2c_write(0x40);
i2c_stop();
while (1)
{
i2c_start();
i2c_write(0x30); //write address for acceleration
i2c_write(0xa8); //MSB,for auto increase the address of comment
i2c_start();
i2c_write(0x31); //read address
ax[0]=i2c_read(0xa8); //x-axis acc. low
i2c_stop();
sprintf(buffer,":%-3d",ax[0]);
lcd_gotoxy(0,0);
lcd_puts(buffer);
};
}
after that i write this code:
while (1)
{
i2c_start();
i2c_write(0x30);
i2c_write(0xa8);
i2c_start();
i2c_write(0x31);
ax[0]=i2c_read(0xa8); //x-axis acc. low
ax[1]=i2c_read(0xa8);
ax[2]=i2c_read(0xa8);
ax[3]=i2c_read(0xa8);
ax[4]=i2c_read(0xa8);
i2c_stop();
sprintf(buffer,":%-3d,%-3d:%-3d",ax[0],ax[1],ax[3]);
lcd_gotoxy(0,0);
lcd_puts(buffer);}
//*********************************
i don’t change my main code
after this code i see this:
on my lcd ican’t see well i see only 0 and very fast and highlight the other number but i can’t detect numbers.
when i write 0 on the i2c_read(0);
i only see the ax[0] on the lcd well.the other numbers locked on 255
please help me i have project in university and i need help
thank you