This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMAG5273: Interrupt threshold triggers at wrong Bz value and fires even when all thresholds are disabled

Part Number: TMAG5273

Tool/software:

Hi TI team,

I’m working with the TMAG5273A2 sensor and have run into two related issues with the interrupt configuration:

  1. Threshold triggers at the wrong Bz value

    • I’ve configured the device to trigger an interrupt when the Bz magnetic field drops below +3 mT.

    • I’m calculating Z_THR_CONFIG using the datasheet formula. For Z_THR_min = 3.0 mT, this gives a register value of ~0x03, which reads back correctly.

    • MAG_THR_DIR is set to 1 (trigger below threshold).

    • THR_HYST is 0 (single threshold comparison).

    • Z_RANGE is set to 0 (±133 mT).

    • The actual Bz readings are smooth and accurate, but the interrupt consistently fires only when Bz drops below around −10 mT, not +3 mT as intended.

  2. Interrupt fires even when all thresholds are disabled

    • I tried disabling all threshold conditions to verify the behavior, but the interrupt line still fires as the Bz field changes.

    • I’ve double-checked that the threshold enable bits are cleared and the registers read back correctly.

Are there any known nuances with how the TMAG5273 handles threshold comparisons, such as signed/unsigned interpretation, 2’s complement encoding, or any default behavior when thresholds are disabled?

Any insight on these two points would be greatly appreciated!

Best regards,

Lovejoy Mhishi

  • Lovejoy,

    Thanks for reaching out on E2E.  I'd be happy to help look into this for you.  Is it possible for you to share with me the full register configuration of the device that you are using?

    Thanks,

    Scott

  • Hi Scott,

    Thanks for your quick response and willingness to assist.

    Please find below the full register configuration I’m currently using for the device. However, I’ve noticed some irregularities with the threshold triggering behavior:

    • The Z-axis threshold is only triggering at the same fixed value, no matter what threshold value I set in the register. The threshold interrupts on Z do not seem to respond correctly to the configured setpoint.

    • Similarly, the X-axis thresholds are triggering at incorrect values that don’t match the configured thresholds.

    • Surprisingly, when the PCB is not enclosed in its housing, the thresholds tend to trigger at the correct values, but this behavior is inconsistent and not reliable.

    Overall, the thresholds don’t seem to be responding correctly to the values I write to their respective registers.

    I’m attaching the relevant register configuration code below for your reference.

    I would appreciate any insights you could provide on this issue.

    Best regards,
    Lovejoy


    /*

    * Configure Registers (p. 25 - p. 28)

    */

    uint8_t device_config_1 =

    (0 << 7) | // CRC_EN = 0

    (0 << 5) | // MAG_TEMPCO = 0

    (0x2 << 2) |// 16x average, 0.8-kSPS (3-axes) or 2.4-kSPS (1 axis)

    (0); // I2C_RD = 00b (standard read)

    uint8_t device_config_2 =

    (0 << 5) | // THR_HYST = 0

    (0 << 4) | // LP_LN = 0

    (0 << 3) | // GLITCH_FILTER = 0

    (0 << 2) | // TRIGGER_MODE = 0

    0x02; // OPERATING_MODE = 10b (Continuous)

    uint8_t sensor_config_1 =

    (0x7 << 4) | // MAG_CH_EN = XYZ

    0x0;

    uint8_t sensor_config_2 =

    (0 << 6) | // THRX_COUNT = 0h

    (0x1 << 5)| // MAG_THR_DIR = 1h

    (0 << 2) | // ANGLE_EN = 0

    (0 << 1) | // X_Y_RANGE = 0 (±133 mT)

    0x00; // Z_RANGE = 0 (±133 mT)

    uint8_t Temp_config =

    (0 << 1) | // T_THR_CONFIG = 0

    (1); // T_CH_EN = 1

    uint8_t int_config_1 =

    (0x1 << 6)| // THRSLD_INT = 1

    (0x1 << 5)| // INT_STATE = 1 (pulsed interrupt)

    (0x1 << 2); // INT_MODE = 001b (INT pin)

    /*

    * Apply all configurations with error checking

    */

    status = TMAG5273_WriteRegister(handle, DEVICE_CONFIG_1, &device_config_1);

    if(status != HAL_OK) {

    return 3;

    }

    status = TMAG5273_WriteRegister(handle, DEVICE_CONFIG_2, &device_config_2);

    if(status != HAL_OK) {

    return 4;

    }

    status = TMAG5273_WriteRegister(handle, SENSOR_CONFIG_1, &sensor_config_1);

    if(status != HAL_OK) {

    return 5;

    }

    status = TMAG5273_WriteRegister(handle, SENSOR_CONFIG_2, &sensor_config_2);

    if(status != HAL_OK) {

    return 6;

    }

    status = TMAG5273_WriteRegister(handle, T_CONFIG, &Temp_config);

    if(status != HAL_OK) {

    return 7;

    }

    status = TMAG5273_WriteRegister(handle, INT_CONFIG_1 , &int_config_1);

    if(status != HAL_OK) {

    return 8;

    }

    /*

    * THRESHORD CONFIGURATION ON STARTUP

    */

    HAL_StatusTypeDef TMAG5273_THR_CONFIG(TMAG5273 *handle, MagneticField *mag, Threshold *limit){

    uint8_t regData;

    HAL_StatusTypeDef status;

    status = TMAG5273_ReadMagneticField(handle, mag);

    limit-> X_THR_min = mag->Bx - 2;

    limit-> X_THR_max = mag->Bx + 2;

    limit-> Z_THR_min = mag->Bz - 3;

    limit-> Z_THR_max = mag->Bz + 3;

    /*

    * Calculate and update X-axis interrupt threshold based on desired limit

    */

    limit-> x_thr_config = (limit-> X_THR_min* 128.0f) / (133.0f * (1 + 0));

    limit-> x_thr_config = (uint8_t)(limit->x_thr_config + 90);

    status = TMAG5273_WriteRegister(handle, X_THR_CONFIG, &limit->x_thr_config);

    status = TMAG5273_ReadRegister(handle, X_THR_CONFIG, &regData);

    printf("X_THR_CONFIG = %d\n\n\n", regData);

    HAL_Delay(1000);

    /*

    * Calculate and update Z-axis interrupt threshold based on desired limit

    */

    limit-> z_thr_config = (limit-> Z_THR_min* 128.0f) / (133.0f * (1 + 0));

    limit-> z_thr_config = (uint8_t)(limit->z_thr_config);

    status = TMAG5273_WriteRegister(handle, Z_THR_CONFIG, (uint8_t *)&limit->z_thr_config);

    status = TMAG5273_ReadRegister(handle, Z_THR_CONFIG, &regData);

    printf("Z_THR_CONFIG = %d\n\n\n", regData);

    HAL_Delay(1000);

    return status;

    }

  • Lovejoy,

    It is interesting that you indicate the enclosure seems to have an impact.  I assume you are comparing the output code observed when the INT pulse occurs?  That is that the magnet is not actively moving when you compare the result?

    Is the T_THR_CONFIG register being written with any value?  I can imagine that if a temperature threshold were being used that it might influence the behavior of the interrupt.  Can you read this setting back to confirm that it is still 0b?  If perhaps the device is flagging for a temperature event might help explain what we are observing.

    I assume you have also done a register read to compare all of your other write commands to the actual latched state in the device?

    Thanks,

    Scott

  • Hi Scott,

    Yes — I’ve checked this in detail:

    • I read back the T_CONFIG register and it correctly returns 1, which just means the temperature channel is enabled for measurement — but no temperature threshold is actually set, so T_THR_CONFIG stays at its default 0b and should not cause any temperature interrupt.

    I’m also continuously reading the raw magnetic field data in the main loop. Even when the interrupt pin is pulsed, the INT pin always triggers when Bz hits around –10 mT whenever the sensor is inside the enclosure with this particular magnet.

    I’ve tried disabling the threshold logic, but it still triggers at –10 mT every time. I confirmed that the other registers keep my writes — I read back all threshold and INT_CONFIG register values and they match. Yet the interrupt always fires at that same Bz point in this setup, and does not clear properly even if I try to turn the thresholds off.

    It does not happen with the same sensor if the magnet or enclosure is changed, so I’m convinced the static bias field is somehow involved, but the threshold and offset logic don’t seem to clear it fully.

    Thanks for looking into this, any ideas are welcome!

    Lovejoy

  • Lovejoy,

    I attempted to configure my EVM using the same settings you indicated:

    Device Config 1 (0x00) = 0x0008

    Device Config 2 (0x01) = 0x0002

    Sensor Config 1 (0x02) = 0x0070

    Sensor Config 2 (0x03) = 0x0020

    T Config (0x07) = 0x0001

    INT Config (0x08) = 0x0064

    With all of the THR Config Registers left at 0x0000, I see no interrupt events even when saturating each input with + and - fields.

    If I configure Z THR Config = 0x03, the INT pin send continuous pulses when no magnetic field is present.  The series of pulses stop when I present a +3mT input for Z.

    If I configure Z THR Config = 0x00FC then I see no pulses when the magnet is removed, but a series of pulses will start when Bz < -3mT

    The settings seem to be correct to me.  Have you tried a swapping out the sensor with another unit to confirm the same behavior on a second device?

    Also I want to be sure I understand correctly, you are reading the Z output value from the device to compare against the threshold detection?  It seems unusual to me that the device logic would change with the enclosure if all of the register settings are the same. Even if there were a secondary magnetic input, the device will report the absolute field that it is exposed to and trigger the threshold based on that.

    When you see unexpected INT signals, are you observing a constant value or a series of pulses?  If it is constant, then I might suspect that something in the enclosure is pulling the pin low.

    Thanks,

    Scott

  • Hi Scott,

    Thanks for your detailed feedback and for double-checking the settings.
    To clarify what I’m seeing on my end:

    • When the circuit is inside the enclosure with the magnet, the INT pin sits at a constant ~3 V once I pull the magnet away(the magnet is also in the enclosure so it moves away to certain degree). I’ve only configured thresholds for the Z axis so far. So instead of seeing clean pulses, the pin just stays high — it’s almost like it’s latched. I have tried another sensor and still this problem persist.

    • However, when the circuit is outside the enclosure, I see proper pulses at 3.3 V whenever an interrupt event is generated, which matches what I’d expect.

    • So, it’s a bit confusing — the exact same configuration seems to behave differently depending on whether the board is in the enclosure or not.

    I’m not entirely sure yet why the circuit misbehaves when it’s inside the enclosure with the magnet — maybe there’s some stray coupling or a constant field that’s holding the INT line high.

    I’ll keep digging into it and might try shielding or repositioning the magnet/enclosure to see if it changes the behavior.
    If you have any additional suggestions, I’d appreciate it!

    Best regards,
    Lovejoy

  • Lovejoy,

    The INT pin is an open-drain pin, so it is stuck in a pull-up condition or is not being triggered.  If all the registers are reading back correctly, then I would suspect that something is interfering with the pull-up voltage.  Is it possible that something in the enclosure is shorting this pin to Vcc?

    Thanks,

    Scott