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.

[参考译文] CCS/MSP430FR2433:TMP112在温度瞬间变化时无响应

Guru**** 2769425 points

Other Parts Discussed in Thread: TMP102, MSP430FR2433, TMP112

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/940255/ccs-msp430fr2433-tmp112-no-response-when-the-temperature-changes-instantaneously

器件型号:MSP430FR2433
主题中讨论的其他器件:TMP102TMP112

工具/软件:Code Composer Studio

尊敬的团队:

我的客户正在将 MSP430FR2433与 TMP102/TMP112搭配使用。

温度变化缓慢时、响应正常。  

但是、 当温度在特定时间段内大幅变化(例如热空气吹出时)时、将不会有响应、一段时间后会更好。

没有这种现象的其他 MCU (AVR)。 SDA\SCL 引脚全部通过10K 电阻器上拉、频率约为100K。

请帮助。

#include 
#include 
#include 
#include 
#define TIMEOUT 60000

void i2c_init (void){
静态 char init=0;
if (!init){
P1REN |= BIT2 | BIT3;
P1OUT |= BIT2 | BIT3;

//如果总线被卡住(SDA =低电平):时钟直到它恢复
P1DIR |= BIT3;
while (!(P1IN & BIT2)){
P1OUT |= BIT3;
_DELAY_CYCLES (8*80);
P1OUT &=~BIT3;
__DELAY_CYCLES (8*80);
}

P1SEL0 |= BIT2 | BIT3; // I2C 引脚
//将 USCI_B0配置为 I2C 模式
UCB0CTLW0 |= UCSWRST; //软件复位被启用
UCB0CTLW0 |= UCMODE_3 | UCMST | UCSYNC;// I2C 模式、主控模式、同步
//到达 UCB0TBCNT 后
UCB0BRW = 10; //波特率= SMCLK / 10 =~100K
UCB0CTL1 &=~UCSWRST;
INIT = 1;
}
}

int i2c_senddata (char *数据,int len){
unsigned int timeout=0;
unsigned int i;
静态 int 虚拟=0;
/*if (dummy){
UCB0TXBUF = 0;
超时= 0;
while (!(UCB0IFG & UCTXIFG0))
if (timeout++>超时)
返回-1;
}
if (dummy = 0) dummy = 1;
*/
//__delay_cycles (5000);
for (i=0;i 超时)
返回3;
}
返回0;
}

int i2c_ReadData (char *数据、int len){
unsigned int timeout=0;
unsigned int i;

memset (data、0、len);
for (i=0;i 超时)
返回-1;


DATA[i]= UCB0RXBUF;
如果(len > 1)
if (i == len-2)
UCB0CTLW0 |= UCTR | UCTXSTP;

}
//while (!(UCB0IFG & UCTXIFG0));
返回0;
}

int i2c_start (char addr、int read){
unsigned int timeout=0;
UCB0I2CSA = addr;
if (读)
UCB0CTLW0 &=~UCTR;
其他
UCB0CTLW0 |= UCTR;
while (UCB0CTL1 & UCTXSTP);
UCB0CTLW0 |= UCTXSTT; // I2C TX、启动条件

while (!(UCB0IFG & UCTXIFG0))
if (timeout++>超时)
返回1;

IF (UCB0IFG 和 UCNACKIFG)
{
UCB0CTL1 |= UCTXSTP; // I2C 启动条件
UCB0IFG = 0; //清除所有 USCI_B0标志
返回2; //检查 NACK
}

if (!read){
UCB0TXBUF = 0;
while (!(UCB0IFG & UCTXIFG0));
}

返回0;
}

int i2c_start2 (char addr、int read){
unsigned int timeout=0;
UCB0I2CSA = addr;
if (读)
UCB0CTLW0 &=~UCTR;
其他
UCB0CTLW0 |= UCTR;
while (UCB0CTL1 & UCTXSTP);
UCB0CTLW0 |= UCTXSTT; // I2C TX、启动条件

while (!(UCB0IFG & UCTXIFG0))
{
if (timeout++>超时)
返回5;
}

IF (UCB0IFG 和 UCNACKIFG)
{
UCB0CTL1 |= UCTXSTP; // I2C 启动条件
UCB0IFG = 0; //清除所有 USCI_B0标志
返回6; //检查 NACK
}

/*if (!read){
UCB0TXBUF = d;
while (!(UCB0IFG & UCTXIFG0));
}*/

返回0;
}

int i2c_stop (void){
unsigned int timeout=0;
UCB0CTLW0 |= UCTR | UCTXSTP; // I2C TX、停止条件
while (UCB0IFG 和 UCTXSTP)
if (timeout++>超时)
返回4;
返回0;
}

int read_reg (int address、int reg){
Int 错误;
char buf[2]={reg};
ERR = i2c_start2 (地址、0);
if (err!= 0) return err;
ERR = i2c_senddata (buf、1);
if (err!= 0) return err;
ERR = i2c_stop ();
if (err!= 0) return err;
_delay_cycles (10000); 等待转换完成 μ s
ERR = i2c_start2 (地址、1);
if (err!= 0) return err;
ERR = i2c_ReadData (buf、2);
if (err!= 0) return err;
返回 buf[0]<<8|buf[1];

}

void write_reg (int address、int reg、int value){
char buf[2]={reg、value};
I2C_start2 (地址、0);
I2C_senddata (buf、2);
I2C_STOP();
}


void tmp117_init (void){
i2C_init();
}

int tmp117_gettemp (void)
{
unsigned int tmp117_raw = 0;
float t = 0;
tmp117_raw = read_reg (0x48、0);
tmp117_raw >= 4;

if (tmp117_raw <= 0x7ff){

t= tmp117_raw * 6.25;

}
if (tmp117_ray>=0xc90){
tmp117_raw =~tmp117_raw;
tmp117_raw &=0x0fff;
tmp117_raw +=1;
t= tmp117_ray*6.25;
t =-t;
}
返回(int)t;
} 

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

    您好 Susan、

    总线是否完全卡滞或是否有任何时钟或数据可见?

    如果连接了调试器、该行为是否也适用、如果是、结果是什么?

    通过如何使用热气肠控制温度、您是否确定不会超出允许的最大温度?

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

    波形如下所示。

    总线始终卡住。 卡滞后、我将执行停止操作或启动操作。

    连接调试器(板载 LaunchPad)的结果相同、发送从器件地址后没有响应。

    我确信不会超过允许值。 ℃温度超过50 ̊ C。

    正常波形:

    异常波形:

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

    在工作地址为0x90而不是0x48、或者我的计数是否不正确?

    实际上、在异常波形上、地址被正确发送、但从器件不会正确应答地址? 您应该在调试器中看到这一点、并且地址没有得到正确的确认吗?

    您是否尝试重置从设备并重试?

    此外、在上波形上、边缘看起来有点慢、因此您可以通过施加5kOhm 或7.5kOhm 等上拉电阻来使上拉电阻变得更强、从而使边缘更加陡峭。

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

    您好:

    地址为0x48 (bit7~bit1),bit0是读/写位、这里是0、因此 bit7~bit0是0x90。

    是的、我确定 地址未被确认。

    我只是在没有 ACK 时执行停止操作、然后开始重试。

    现在、我在 上拉时使用了10kOhm。

     我将根据您的建议再次尝试: 重置从器件并 将10kOhm 替换 为5kOhm  

    谢谢!

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

    您好 Susan、

    您是否能够尝试不同的上拉值以使其正常工作? 如果缺少任何内容、请告诉我、否则我将在本周结束前关闭此主题。