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/MSP430FR6972:Wire.h 不能与 CCS V8配合使用。

Guru**** 2539500 points
Other Parts Discussed in Thread: ENERGIA

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

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/733441/ccs-msp430fr6972-wire-h-is-not-working-with-ccs-v8

器件型号:MSP430FR6972
主题中讨论的其他器件:Energia

工具/软件:Code Composer Studio

我正在尝试在 CCS 中导入 Energia 代码、但它无法正常工作。 我正在附加我的代码,您可以通过将代码导入为 enegia 代码和进行调试,轻松地重新创建此错误。  

#include "Wire.h"
#define TS 0x48
#include 
unsigned long i、a;
void setup(){

Serial1.begin(9600);
SERIAL1.println ("温度数据记录器");

Wire.setModule(1);
Wire.begin();



//开始 I2C 传输

Wire.beginTransmission(TS);

//选择配置寄存器
Wire.write (0x01);
//设置分辨率= 12位、正常操作、比较器模式
Wire.write (0x60);
Wire.write (0x00);
//停止 I2C 传输
wire.endTransmission ();
延迟(300);

SERIAL1.println ("传感器初始化");

}

void loop (){
//Serial.println ("正在工作");
Serial1.println ("正在工作");

浮点温度= Read_temperature ();
Serial1.print ("摄氏温度:");
SERIAL1.PRINT (TEMPRURE);
SERIAL1.println("C");
delay (5000);
}



float read_temperature ()
{
Serial.println ("读取温度");
unsigned data[2];

//开始 I2C 传输
Wire.beginTransmission(TS);
//选择数据寄存
器 Wire.write (0x00);
//停止 I2C 传输
Wire.endTransmission ();
delay (300);

//请求2字节的日期
Wire.From (TS、2

);
msb (
如果可用)= 2);// temp (2)= 2字节(2)

DATA[0]= Wire.read();
DATA[1]= Wire.Read();
}
//将数据转换为12位
int temp =((data[0]* 256)+(data[1]& 0xF0))/ 16;
if (temp > 2047)
{
temp -= 4096;
}
float cTemp = temp * 0.0625;
//将数据输出到串行监视器
返回 cTemp;
}




这是我得到的误差。 我有3个不同的 MCU。 4133、6989和6972。 我认为这是一个兼容的问题,但似乎是一个共同的问题。  

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

    您的问题与 MSP430而不是 CCS 有关。
    TI 不支持 Energia、我建议您访问 Energia 论坛 :https://forum.43oh.com/
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    我是否应该请求将此主题移至 MSP430论坛?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    只需将您的问题发布到 MSP430论坛。