2018-06-27 07:13 PM
Can anyone tell me how to get a DRDY_MAG on the LSM303C? Is that the correct interrupt to try and get for the magnetometer? I'm trying to get mag data at about 10Hz and want an interrupt. Nothing I have done has caused the interrupt to happen (using an oscilloscope to see the interrupt).
I have two spark fun breakout boards. The accelerometer works fine. The magnetometer does not call any interrupt that I can see. The documentation shows the pin, but it doesn't say anything about it.
On startup, I am doing a reset of both the accelerometer and the magnetometer. WHO_AM_I reads correctly for both.
I've attached the data sheet I'm using -- you can search for DRDY_MAG and find very little.
My configuration looks like this (I'm hoping it's self explanatory):
/* Accelerometer */
LSM_FIFO_CTRL reg_fifo_ctrl; reg_fifo_ctrl.FMODE = LSM303C_A_FIFO_MODE_OFF; lsm303c_set_register(true, LSM303C_REG_FIFO_CTRL, reg_fifo_ctrl.Byte);LSM_CTRL_REG1_A reg_ctrl1_a;
reg_ctrl1_a.XEN = true; reg_ctrl1_a.YEN = true; reg_ctrl1_a.ZEN = true; reg_ctrl1_a.BDU = true; reg_ctrl1_a.ODR = LSM303C_A_OUTPUT_DATA_RATE_10_HZ; reg_ctrl1_a.HR = false; lsm303c_set_register(true, LSM303C_REG_CTRL_REG1_A, reg_ctrl1_a.Byte);LSM_CTRL_REG2_A reg_ctrl2_a;
reg_ctrl2_a.Byte = 0;lsm303c_set_register(true, LSM303C_REG_CTRL_REG2_A, reg_ctrl2_a.Byte);
LSM_CTRL_REG3_A reg_ctrl3_a;
reg_ctrl3_a.Byte = 0; reg_ctrl3_a.INT_XL_DRDY = true; lsm303c_set_register(true, LSM303C_REG_CTRL_REG3_A, reg_ctrl3_a.Byte);LSM_CTRL_REG4_A reg_ctrl4_a;
reg_ctrl4_a.Byte = 0; lsm303c_set_register(true, LSM303C_REG_CTRL_REG4_A, reg_ctrl4_a.Byte);LSM_CTRL_REG5_A reg_ctrl5_a;
reg_ctrl5_a.Byte = 0; lsm303c_set_register(true, LSM303C_REG_CTRL_REG5_A, reg_ctrl5_a.Byte);/* Magnetometer */
LSM_CTRL_REG1_M reg_ctrl1_m; reg_ctrl1_m.Byte = 0; reg_ctrl1_m.DO = LSM303C_M_OUTPUT_DATA_RATE_1_2; reg_ctrl1_m.OM = LSM303C_M_XY_OP_MODE_MEDIUM_PERF; lsm303c_set_register(false, LSM303C_REG_CTRL_REG1_M, reg_ctrl1_m.Byte);LSM_CTRL_REG2_M reg_ctrl2_m;
reg_ctrl2_m.Byte = 0; reg_ctrl2_m.FS = LSM303C_M_FULL_SCALE_16_GAUSS; lsm303c_set_register(false, LSM303C_REG_CTRL_REG2_M, reg_ctrl2_m.Byte);LSM_CTRL_REG3_M reg_ctrl3_m;
reg_ctrl3_m.Byte = 0; reg_ctrl3_m.MD = LSM303C_M_SYS_OP_MODE_SINGLE_CONVERSION; lsm303c_set_register(false, LSM303C_REG_CTRL_REG3_M, reg_ctrl3_m.Byte);LSM_CTRL_REG4_M reg_ctrl4_m;
reg_ctrl4_m.Byte = 0; reg_ctrl4_m.OMZ = LSM303C_M_Z_OP_MODE_MEDIUM_PERF; lsm303c_set_register(false, LSM303C_REG_CTRL_REG4_M, reg_ctrl4_m.Byte);LSM_CTRL_REG5_M reg_ctrl5_m;
reg_ctrl5_m.Byte = 0; reg_ctrl5_m.BDU = false; lsm303c_set_register(false, LSM303C_REG_CTRL_REG5_M, reg_ctrl5_m.Byte);lsm303c_set_register(false, LSM303C_REG_INT_THS_L_M, 0x0);
lsm303c_set_register(false, LSM303C_REG_INT_THS_H_M, 0x0);LSM_INT_CFG_M reg_int_cfg_m;
reg_int_cfg_m.IEN = false; reg_int_cfg_m.IEL = false; reg_int_cfg_m.IEA = false; reg_int_cfg_m.ONE = 1; /* Must be one */ reg_int_cfg_m.ZERO = 0; /* Must be zero */ reg_int_cfg_m.ZIEN = false; reg_int_cfg_m.YIEN = false; reg_int_cfg_m.XIEN = false; lsm303c_set_register(false, LSM303C_REG_INT_CFG_M, reg_int_cfg_m.Byte);2018-07-09 02:17 AM
The device generated magnetometer DRDY signal all the time, no particular settings is needed.
2018-07-09 08:19 PM
Then I'm confused I guess, because my o-scope shows nothing happening on the DRDY pin. Anybody know why?
2018-07-13 04:12 AM
Can you please check that the pin is not accidentally shorted? If it is connected to a MCU please check the GPIO is configured as input and dons't force VDD or GND.
Are you able to get the magnetometer data?
2018-07-13 09:30 PM
It's not connected to anything except my o-scope and it's not shorted. I can read data, I just don't know if it's noise or data.
2018-07-16 04:26 AM
You configured the mode to single conversion:
LSM_CTRL_REG3_M reg_ctrl3_m;
reg_ctrl3_m.Byte = 0;reg_ctrl3_m.MD = LSM303C_M_SYS_OP_MODE_SINGLE_CONVERSION;lsm303c_set_register(false, LSM303C_REG_CTRL_REG3_M, reg_ctrl3_m.Byte);Please change it to Continuous-conversion mode and then check the DRDY signal.