主题中讨论的其他部件: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