AnsweredAssumed Answered

STM32F4 and LSM303 no reading data

Question asked by anton.bogdan on Aug 10, 2014
Latest reply on Aug 11, 2014 by anton.bogdan
Hi all,
 i recently started working on a orientation project using iNemo aplication, despite the dificulty of using pre build sensor libs, i said "i`ll build my own".
Said and done, but when i try to read a single register there is 0x00 data on the buss
The I2C works fine, except after sending the read comand ( 0x33) the data is 0x00 0x00
I tryied this reading only one axis, for example the X axis.
Bellow is my init routine and the reading function

void LSM303_init(){
i2c_send_cmd(awAddr, CTRL_REG2_A, 0x00);
i2c_send_cmd(awAddr, CTRL_REG1_A, 0x77);  // normal mode,data rate to 400hz
i2c_send_cmd(awAddr, CTRL_REG3_A, 0x00); // disable interrupts for DRDY and Click
i2c_send_cmd(awAddr, CTRL_REG4_A, 0x00);  // full scale 2G, little endian
i2c_send_cmd(awAddr, CTRL_REG5_A, 0x00); //fifo disable,boot normal
i2c_send_cmd(awAddr, CTRL_REG6_A, 0x00);//disable more interrupts
i2c_send_cmd(awAddr, FIFO_CTRL_REG_A, 0x00); // bypass fifo
i2c_send_cmd(awAddr, INT1_CFG_A, 0x00); // more interrupts disabled
i2c_send_cmd(awAddr, INT2_THS_A, 0x00); // more interrupts disabled
i2c_send_cmd(awAddr, CRA_REG_M, 0x94); // set magnetometer data rate to 30hz, temp sensor enable
i2c_send_cmd(awAddr, CRB_REG_M, 0x40); // set magnetometer gain to 1.9Gauss
i2c_send_cmd(awAddr, MR_REG_M, 0x00); // set mag continouse conversion mode

The read function
void LSM303_Read(uint16_t x_a){
//uint16_t x_a;
i2c_wrAddr(awAddr); //0x32
i2c_Wrbyte(OUT_X_H_A); // 0x29 Select Acc Y register
i2c_start_com(); // restart signal
uint8_t  x_h_a=i2c_rdAck();// get acc x MSB;
uint8_t  x_l_a=i2c_rdNack(); // get acc x LSB;
I2Cx->CR1 |= I2C_CR1_STOP; /* Generate a STOP condition */  

Bellow are some screent shots taken with logic analizer on the bus. I am missing something in the config registers?