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: TMAG5273 ws mode interrupt triggered problem

Part Number: TMAG5273

There is a strange issue, within the trigger threshold range, entering ws mode will immediately wake up. For example, if the current magnetic field intensity is 1mT and I set the threshold to be less than 1.25mT, an interrupt will occur. Then, if I configure it to enter ws mode, it will be immediately awakened. After waking up, I configure it to run in continuous conversion mode for about 10 seconds, and continue to repeat the previous operation. If I configure it to enter ws mode, it will also be immediately awakened.The following is the configuration of the two modes switching.

RetTypeDef hall_sensor_logic_set_continuous_mode(void)
{
    RetTypeDef ret = RET_OK;
    uint8_t value;

    if (g_op_mode == CONTINUOUS_MODE)
    {
        DEBUG_LOG_ERROR("[HALL] already in continuous mode.\r\n");
        return RET_OK;
    }
    g_op_mode = CONTINUOUS_MODE;

    DEBUG_LOG_ERROR("[HALL] set continuous mode.\r\n");

    value = 0x14;
    hall_sensor_hal_write_byte(TMAG5273_REG_DEVICE_CONFIG_1, &value);

    value = 0x87;
    hall_sensor_hal_write_byte(TMAG5273_REG_SENSOR_CONFIG_1, &value);

    value = 0x00;
    hall_sensor_hal_write_byte(TMAG5273_REG_INT_CONFIG_1, &value);

    value = 0x14;
    hall_sensor_hal_write_byte(TMAG5273_REG_SENSOR_CONFIG_2, &value);

    value = 0xC5;
    hall_sensor_hal_write_byte(TMAG5273_REG_MAG_GAIN_CONFIG, &value);

    value = 0x02;
    hall_sensor_hal_write_byte(TMAG5273_REG_DEVICE_CONFIG_2, &value);

    return ret;
}


RetTypeDef hall_sensor_logic_set_w_s_mode(void)
{
    RetTypeDef ret = RET_OK;
    uint8_t value;

    if (g_op_mode == W_S_MODE)
    {
        DEBUG_LOG_ERROR("[HALL] already in W&S mode.\r\n");
        return RET_OK;
    }
    g_op_mode = W_S_MODE;

    DEBUG_LOG_ERROR("[HALL] set W&S mode.\r\n");

    value = 0x14;
    hall_sensor_hal_write_byte(TMAG5273_REG_DEVICE_CONFIG_1, &value);

    value = 0x17;
    hall_sensor_hal_write_byte(TMAG5273_REG_SENSOR_CONFIG_1, &value);

    value = 0x20;
    hall_sensor_hal_write_byte(TMAG5273_REG_SENSOR_CONFIG_2, &value);

    value = 0x64;
    hall_sensor_hal_write_byte(TMAG5273_REG_INT_CONFIG_1, &value);

    value = 0x04;
    hall_sensor_hal_write_byte(TMAG5273_REG_X_THR_CONFIG, &value);

    value = 0x23;
    hall_sensor_hal_write_byte(TMAG5273_REG_DEVICE_CONFIG_2, &value);

    return ret;
}

  • Hi Shawn,

    Thank you for posting to the Sensors forum!

    Looking at your code, it appears that you are writing 0x20 to SENSOR_CONFIG_2. With this configuration, MAG_THR_DIR = 1h, which sets an interrupt to occur when the field is below the threshold.

    Because your threshold is set to 1.25mT and your field is 1mT, the condition for an interrupt is met and therefore an interrupt should occur. 

    Best,

    ~Alicia