SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By gilo12
Hi all,

I am activating a SparkFun 6 Degrees of Freedom Breakout - LSM303C with pic18f86j90. My goal is to get an acceleration interrupt on XYZ axis, then go and read the magnetometer position and make some descision upon it.

But, i am not able to get the INT_XL pin working on "active low".

The lsm303c INT_XL pin is configured as "active low" and "open-drain". see code below.

I have configured the pic18 port as input with weak pull-up. The breakout board does react to accreleration, but works the opposite way: normally signal is low and when interrupt happenns, INT_XL goes high for about 40ms and then comes back to low.

The accelerometer initialization routine is:
void LSM303C_AccInit(void)
uint8_t result = 0;

ACCELERO_IO_Write(LSM303C_CTRL_REG1_A, 0b00100101); // disable y axis to avoid mg

ACCELERO_IO_Write(LSM303C_CTRL_REG2_A, 0b00000000);

ACCELERO_IO_Write(LSM303C_CTRL_REG3_A, 0b00001000); //was 1101

ACCELERO_IO_Write(LSM303C_CTRL_REG4_A, 0b00000000);

ACCELERO_IO_Write(LSM303C_CTRL_REG5_A, 0b00000011); //interrupt active low, open-drain

/// ACCELERO_IO_Write(LSM303C_CTRL_REG7_A, 0b00000100); //1: interrupt request latched Cleared by reading IG_SRC[2:1]_A register

ACCELERO_IO_Write(LSM303C_FIFO_CTRL, 0b01000000); //stream mode,

ACCELERO_IO_Write(LSM303C_IG_CFG1_A, 0b11100010); //y interrupt disabled


ACCELERO_IO_Write(LSM303C_IG_DUR1_A, 0b10000001); //interrupt delay


Can you please let me know what is wrong with my config?