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:使用 LP-MSPM0L1306 测得的 TMAG5273EVM 温度值

Guru**** 2465890 points
Other Parts Discussed in Thread: LP-MSPM0L1306, TMAG5273, TMAG5273EVM, TI-SCB

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/sensors-group/sensors/f/sensors-forum/1552383/tmag5273-temperature-value-measured-tmag5273evm-with-lp-mspm0l1306

器件型号:TMAG5273
主题中讨论的其他部件:LP-MSPM0L1306、、

工具/软件:

您好的团队、

我的客户正在评估 TMAG5273 以使用 LP-MSPM0L1306 提供的温度传感器。

这是从 MCU 发送到 TMAG5273EVM 的寄存器配置。

  • DEVICE_CONFIG_1:0x00(寄存器地址)→0x01h(设置值)
    I2C_RD、用于选择 16 位数据的读取模式为 1 字节 I2C 读取命令 (CRC 被禁用、CRC_EN = 0b)
  • DEVICE_CONFIG_2:0x01(寄存器地址)→0x02h(设置值)  
    将工作模式更改为连续测量模式
  • T_CONFIG:0x07h(寄存器地址)(T_CH_EN)→0x01h(设置值)  
    启用温度传感器

从温度传感器的寄存器地址读取数据(总共 16 位数据)后、发送到 MCU 寄存器的结果如下所示。

  • 结果:0x32“、“0x50",“,"0x00"、"0x00"</s>“ “
    我认为这些结果将 T_MSB 显示为 0x32、T_LSB = 0x50 且 CONV_STATUS = 0x00。
    然后使用以下公式转换结果。 结果表明、–50℃ 但我们评估的温室为 25℃。

您能否检查以下代码并查看其中的任何错误代码?

/*
 * 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);
    }
}

提前感谢您。

Kenley

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Kenley:

    感谢您发布到传感器论坛!

    SENSOR_CONFIG_1 中已将 MAG_CH_EN 设置为什么?

    您是否能够共享从逻辑分析仪捕获的从微控制器读回的完整数据?  

    此致、

    ~Alicia

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    嗨、Alicia

    感谢您的支持。

    我们不设置 MAG_CH_EN、即使不使用配置数据、也建议发送配置数据吗?  

    此致、

    Kenley

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Kenley:

    不必设置 MAG_CH_EN、我只是询问是否进行了此设置。

    使用与模拟 Discovery 2 套件相同的设置、我能够成功读回温度数据、因此我不知道为什么它似乎不适合您。

    以防万一、您可以尝试启用 MAG_CH_EN 来查看它是否有所帮助? 或者、如果可能、您是否可以尝试使用 GUI 对此 进行测试(注意:要执行此操作,您需要使用 TI-SCB) 来查看是否获得相同的结果?

    此致、

    ~Alicia