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.

[参考译文] MSP430G2230:MSP430G2230和 I2C

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/919216/msp430g2230-msp430g2230-and-i2c

器件型号:MSP430G2230

我正在启动一个新项目、希望使用 USI 库进行 I2C 通信。

我这些示例、但在编译时未定义?

我的代码:

#include "stdint.h"
#include "USI_I2CMaster.h"

#include "msp430g2230.h"

//传感器的默认从地址为0x29

int door_state=0、mub=1、iv1=0;
unsigned int ic0=0、ic2=1、iv、Iout、k=0、m=0、in=0、p=500、ivi=20;
unsigned int lDS=0、ACK1=1、slvw=0x28、slvr=0x29;
unsigned char c;


int main (空)

WDTCTL = WDTPW + WDTHOLD;//停止看门狗计时器
P1REN=0x1B;//正确终止不可用的 Port1引脚(P1.0/1/3/4)
P1DIR = 0x24;//将 P1设置为输出方向
P1OUT=0x00;
TACCR0=47300;//测量时间为333毫秒。
TACCTL0=CCIE;
TACTL=MC_1_ID_3|tassel_2|TACLR;
MUB=1;

TI_USI_I2C_MasterInit (USIDIV_7+USISSEL_2+USICKPL、StatusCallback);//此处出现错误为"未定义的 StatusCallback "


_enable_interrupt ();
对于(;)

_low_power_mode_0 ();

#pragma vector=TIMERA0_vector
_interrupt void TA0_ISR (void)

ic0++;
if (LDS=0 &&(ic0&1)=0)//启动状态

IC2++;
Iout=((ic2&1)<<2)|((ic2&2)<<4);

P1OUT=Iout;
if (ic2>12)

LDS=1;
IC2=0;


如果(LDS = 1)则为其他

P1OUT=0x24;

int statusCallback (unsigned char c)

返回 TI_USI_EXIT_LPM;

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

    编译器不知道该回调函数、直到您将其告知它。 在 main()前面移动它的代码,该代码会发生变化。 或添加函数原型以告知编译器。

    此外、使用"插入代码"按钮进行编码!

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

    谢谢、无法想象编译器无法解析。