主题中讨论的其他器件:MSP432P401R、 BOOSTXL-BATPAKMKII
工具/软件:Code Composer Studio
您好、TI 团队、
我使用 MSP430F5529LP 通过 I2C 与 BOOSTXL‑BATPAKMKII 进行通信。
这是 一个来自 USCI_B_i2c.c (MSP430 driverlib)的函数 USCI_B_I2C_masterSendSingleByteWithTimeout 的代码源
bool USCI_B_I2C_masterSendSingleByteWithTimeout (uint16_t baseAddress、 uint8_t txData、 uint32_t 超时) { //为第二个超时情形创建变量 uint32_t timeout2 =超时; //存储当前 TXIE 状态 uint8_t txieStatus = HWREG8 (baseAddress + OFS_UCBxIE)& UCTXIE; //禁用发送中断使能 HWREG8 (baseAddress + OFS_UCBxIE)&=~(UCTXIE); //发送启动条件。 HWREG8 (baseAddress + OFS_UCBxCTL1)|= UCTR + UCTXSTT; //轮询发送中断标志。 while ((!(HWREG8 (baseAddress + OFS_UCBxIFG)& UCTXIFG))&&-超时) { ; } //检查传输是否超时 if (超时=0) { 返回(status_fail); } //发送单字节数据。 HWREG8 (baseAddress + OFS_UCBxTXBUF)= txData; //轮询发送中断标志。 while ((!(HWREG8 (baseAddress + OFS_UCBxIFG)& UCTXIFG))&&--timeout2)//=== >此处为代码块 { ; } //检查传输是否超时 if (timeout2 = 0) { 返回(status_fail); } //发送停止条件。 HWREG8 (baseAddress + OFS_UCBxCTL1)|= UCTXSTP; //在再次启用中断之前清除发送中断标志 HWREG8 (baseAddress + OFS_UCBxIFG)&=~(UCTXIFG); //恢复发送中断使能 HWREG8 (baseAddress + OFS_UCBxIE)|= txieStatus; 返回(STATUS_SUCCESS); } void USCI_B_I2C_masterSendMultiByteStart (uint16_t baseAddress、 uint8_t txData) { //存储当前发送中断使能 uint8_t txieStatus = HWREG8 (baseAddress + OFS_UCBxIE)& UCTXIE; //禁用发送中断使能 HWREG8 (baseAddress + OFS_UCBxIE)&=~(UCTXIE); //发送启动条件。 HWREG8 (baseAddress + OFS_UCBxCTL1)|= UCTR + UCTXSTT; //轮询发送中断标志。 while (!(HWREG8 (baseAddress + OFS_UCBxIFG)& UCTXIFG)) { ; } //发送单字节数据。 HWREG8 (baseAddress + OFS_UCBxTXBUF)= txData; //恢复发送中断使能 HWREG8 (baseAddress + OFS_UCBxIE)|= txieStatus; }
在 E2E 论坛上进行了一些研究后、我知道这可能是 SDA 和 SCL 问题上的上拉电阻器。 这是正确的问题吗??
如果是,如何在 SDA 和 SCL 引脚上设置上拉电阻器?
我将这一行代码放入代码中、但它没有解决我的问题。
P4REN |= 0x06;
谢谢你。