2015-09-01 03:11 AM
Hi, i've some problem reading magnetic data from LIS3MDL.
I initialize LIS3MDL://configure device
response = LIS3MDL_W_FullScale(LIS3MDL_FS_16Ga);
response = LIS3MDL_W_OutputDataRate(LIS3MDL_DO_80Hz);
response = LIS3MDL_W_BlockDataUpdate(LIS3MDL_BDU_ENABLE);
response = LIS3MDL_W_OperatingModeXY(LIS3MDL_OM_ULTRA_HIGH);
response = LIS3MDL_W_OperatingModeZ(LIS3MDL_OMZ_ULTRA_HIGH);
response = LIS3MDL_W_SystemOperatingMode(LIS3MDL_MD_CONTINUOUS);
Then i read data from register but i receive data that varies too (i.e. from -1000 to +2000, this values are only the reading from the registers)
LIS3MDL_Get_Magnatic(u8_t *buff) {
u8_t i, j, k;
u8_t numberOfByteForDimension;
numberOfByteForDimension = 6 / 3;
k = 0;
for (i = 0; i < 3; i++) {
for (j = 0; j < numberOfByteForDimension; j++) {
if (!LIS3MDL_ReadReg(LIS3MDL_OUTX_L + k, &buff[k]))
return MEMS_ERROR;
k++;
}
}
i16_t value;
u8_t *valueL = (u8_t *) (&value);
u8_t *valueH = ((u8_t *) (&value) + 1);
LIS3MDL_ReadReg(LIS3MDL_OUTX_L, valueL);
LIS3MDL_ReadReg(LIS3MDL_OUTX_H, valueH);
}
#lis3mdl