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.

[参考译文] MSP430FR2311:I2C Driverlib 问题

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/763674/msp430fr2311-i2c-driverlib-questions

大家好、我还有一个问题。

实际上、我将使用 Drivelib I2C 函数。

但它仅提供单字节发送功能。

这是功能。

void eUSCI_B_I2C_masterSendSingleByte (uint16_t baseAddress、
uint8_t txData)
{
//存储当前 TXIE 状态
uint16_t txieStatus = HWREG16 (baseAddress + OFS_UCBxIE)& UCTXIE;

//禁用发送中断启用
HWREG16 (UCBxIE)+ UCBxIE ~

条件+ UCBxIE + UCBxIE。
HWREG16 (baseAddress + OFS_UCBxCTLW0)|= UCTR;

HWREG16 (baseAddress + OFS_UCBxCTLW0)|= UCTXSTT;

//轮询发送中断标志。
while (!(HWREG16 (baseAddress + OFS_UCBxIFG)& UCTXIFG)
){
;
}

//发送单字节数据。
HWREG16 (baseAddress + OFS_UCBxTXBUF)= txData;

//轮询发送中断标志。
while (!(HWREG16 (baseAddress + OFS_UCBxIFG)& UCTXIFG)
){
;
}

//发送停止条件。
//HWREG16 (baseAddress + OFS_UCBxCTLW0)|= UCTXSTP;

//在再次启用中断之前清除发送中断标志
HWREG16 (baseAddress + OFS_UCBxIFG)&&~(UCTXIFG);

//恢复发送中断使能
HWREG16 (baseAddress + OFS_UCBxIFG);= UCBxIE



但我想使用2字节发送函数。

我如何修改它?

请给我一些提示吗?

谢谢!

再见

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

    嗨、Minkyo、

    由于我们在另一个线程中解决了您的问题、我已将其拆分为新线程。  此外,请使用软件发布工具(. 按钮)以发布代码。  使其可读性最高、以便社区可以更快地为您提供反馈。  

    此外、还有多字节函数。  请参阅 《适用于 MSP430FR2xx_4xx 器件的 Driverlib API 指南》。  

    我相信流程会像这样:

    EUSCI_B_I2C_masterSendMultiByteStart (uint16_t baseAddress、uint8_t txData);
    
    EUSCI_B_I2C_masterSendMultiByteNext (uint16_t baseAddress、uint8_t txData);
    
    EUSCI_B_I2C_SendMultiByteNext (uint16_t baseAddress、 uint8_t txData);
    
    EUSCI_B_I2C_masterSendMultiByteStop (uint16_t baseAddress); 

    让我看看是否有任何使用此功能的软件示例。   

    谢谢、

    JD

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

    TI Resource Explorer 中有一个 MasterTXMultiple 字节 driverlib 示例:dev.ti.com/.../

    它显示了如何发送多个字节并由中断驱动。

    谢谢、
    JD