TMAG5273: Temperature Value Measured TMAG5273EVM with LP-MSPM0L1306

Part Number: TMAG5273
Other Parts Discussed in Thread: LP-MSPM0L1306, ,

Tool/software:

Hi team,

My customer is evaluating TMAG5273 to use the temperature sensor by LP-MSPM0L1306.

Here is the register configuration sent from MCU to TMAG5273EVM.

  • DEVICE_CONFIG_1: 0x00(register address) → 0x01h (settings value)
    I2C_RD to select read mode to 1-Byte I2C Read Command for 16-Bit Data With CRC Disabled, CRC_EN = 0b
  • DEVICE_CONFIG_2: 0x01(register address) → 0x02h (settings value)
    Change operation mode to continuous measure mode
  • T_CONFIG: 0x07h(register address) (T_CH_EN) → 0x01h (settings value)
    Enable the temperature sensor

After reading the data from Register Address of Temperature Sensor – Total of 16bit data, the results sent to the mcu register is as following.

  • Results : 0x32", "0x50", "0x00"
    I think these result shows the T_MSB as 0x32 and T_LSB = 0x50 and CONV_STATUS = 0x00.
    After i convert the results using following formula. The results says that -50℃ but the temperature room we evaluated is 25℃.

Could you please check the following code and look any mistaken code there ?

/*
 * Copyright (c) 2021, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "ti_msp_dl_config.h"

/*
 * Number of bytes to send from Controller to target.
 *  This example uses FIFO with polling, and the maximum FIFO size is 8.
 *  Refer to interrupt examples to handle larger packets
 */
#define I2C_TX_PACKET_SIZE (3)

/*
 * Number of bytes to received from target.
 *  This example uses FIFO with polling, and the maximum FIFO size is 8.
 *  Refer to interrupt examples to handle larger packets
 */
#define I2C_RX_PACKET_SIZE (3)

/* Data sent to the Target to set register */
uint8_t gTxPacket[I2C_TX_PACKET_SIZE] = {
    0x00, 0x01, [2]=0x02};
uint8_t gTxPacketTemp[2] = {
    0x07,[1]=0x01};

/* Data received from Target */
volatile uint8_t gRxPacket[I2C_RX_PACKET_SIZE];

/* I2C Target address */
#define I2C_TARGET_ADDRESS (0x35)
//#define I2C_TARGET_CONFIG_ADDRESS (0x00)
//#define I2C_TARGET_TEMP_ADDRESS (0x07)
//#define I2C_READ_ADDRESS (0x10)

int main(void)
{
    SYSCFG_DL_init();

    /* Set LED to indicate start of transfer */
    DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);

    /*
     * Fill FIFO with data. This example will send a MAX of 8 bytes since it
     * doesn't handle the case where FIFO is full
     */
    DL_I2C_fillControllerTXFIFO(I2C_INST, &gTxPacket[0], I2C_TX_PACKET_SIZE);

    /* Wait for I2C to be Idle */
    while (!(
        DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))
        ;

  DL_I2C_startControllerTransfer(I2C_INST, I2C_TARGET_ADDRESS,
        DL_I2C_CONTROLLER_DIRECTION_TX, I2C_TX_PACKET_SIZE);

    /* Poll until the Controller writes all bytes */
    while (DL_I2C_getControllerStatus(I2C_INST) &
           DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
        ;

    /* Trap if there was an error */
    if (DL_I2C_getControllerStatus(I2C_INST) &
        DL_I2C_CONTROLLER_STATUS_ERROR) {
        /* LED will remain high if there is an error */
        __BKPT(0);
    }

    DL_I2C_fillControllerTXFIFO(I2C_INST, &gTxPacketTemp[0], I2C_TX_PACKET_SIZE);
    /* Wait for I2C to be Idle */
    while (!(
        DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))
        ;

    /* Send the packet to the controller.
     * This function will send Start + Stop automatically.
     */
    DL_I2C_startControllerTransfer(I2C_INST, I2C_TARGET_ADDRESS,
        DL_I2C_CONTROLLER_DIRECTION_TX, I2C_TX_PACKET_SIZE);

    /* Poll until the Controller writes all bytes */
    while (DL_I2C_getControllerStatus(I2C_INST) &
           DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
        ;

    /* Trap if there was an error */
    if (DL_I2C_getControllerStatus(I2C_INST) &
        DL_I2C_CONTROLLER_STATUS_ERROR) {
        /* LED will remain high if there is an error */
        __BKPT(0);
    }

    /* Wait for I2C to be Idle */
    while (!(
        DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))
        ;
    /* Add delay between transfers */
    delay_cycles(1000);

    /* Send a read request to Target */
    DL_I2C_startControllerTransfer(I2C_INST, I2C_TARGET_ADDRESS,
        DL_I2C_CONTROLLER_DIRECTION_RX, I2C_RX_PACKET_SIZE);

    /*
     * Receive all bytes from target. LED will remain high if not all bytes
     * are received
     */
    for (uint8_t i = 0; i < I2C_RX_PACKET_SIZE; i++) {
        while (DL_I2C_isControllerRXFIFOEmpty(I2C_INST))
            ;
        gRxPacket[i] = DL_I2C_receiveControllerData(I2C_INST);
    }

    /* If write and read were successful, toggle LED */
    while (1) {
        DL_GPIO_togglePins(GPIO_LEDS_PORT,
            GPIO_LEDS_USER_LED_1_PIN | GPIO_LEDS_USER_TEST_PIN);
        delay_cycles(16000000);
    }
}

Thank you in advance.

Kenley

  • Hi Kenley,

    Thank you for posting to the Sensors forum!

    What do you have MAG_CH_EN set to in SENSOR_CONFIG_1?

    Are you able to share a capture from a logic analyzer of the full data read back from the microcontroller? 

    Best,

    ~Alicia

  • Hi Alicia

    Thank you for the support.

    We do not set for MAG_CH_EN, is it recommended to send configuration data even though we do not use it ? 

    regards,

    Kenley

  • Hi Kenley,

    MAG_CH_EN should not have to be set, I was just asking in case it was.

    Using the same settings that you are with an analog discovery 2 kit, I was able to successfully read back the temperature data, so I am not sure why it doesn't seem to be working for you.

    Just in case, can you try enabling MAG_CH_EN to see if that helps? Alternatively, if possible, could you try testing this out with the GUI (Note: to do this you will need the TI-SCB) to see if you are getting the same results?

    Best,

    ~Alicia