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/TMS570LS1227:具有中断的 I2C 通信

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/599148/ccs-tms570ls1227-i2c-communication-with-interrupts

器件型号:TMS570LS1227
主题中讨论的其他器件:HALCOGEN

工具/软件:Code Composer Studio

你(们)好

在主控模式下(我正在使用 TMS570LS12x 和 HALCoGen)、是否有任何与中断进行 I2C 通信的示例项目?
此时、我在轮询模式下使用 I2C 通信接口。 它可以工作、但有时我会遇到发送函数(while ((i2c->STR &(uint32) I2C_TX_INT)== 0U)和接收函数(while (((i2c->STR &(uint32) I2C_RX_INT)=0U))中的阻塞循环问题。 我不喜欢这个循环、并且希望更改为中断模式。 一个示例对我很有帮助。

谢谢、致以最诚挚的问候

 

Simon

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

    您好、Simon、

    1、使能 I2C 中断:VIM 中的通道66

    2.启用 I2C RX 中断(ICRRDY)

    示例是使用环回模式进行测试:

    void main (void)

      uint32 buf_size = bsize;

      uint8 * t_buff =&TX_Pack[0];

      uint8 * r_buff =&RX_Pack[0];

      _enable_interrupt_();

      i2cInit();             

      i2cSetOwnAdd (i2cREG1、Own_add);  

      i2cEnableLoopback (i2cREG1);    

      i2c 接收器(i2cREG1、16、r_buff);

      i2cSetStart (i2cREG1);

      while (buf_size--)

      {

        i2cSendByte (i2cREG1、* t_buy++);     

      }

      i2cClearSCD (i2cREG1);

      i2cDisableNotification (i2cREG1、I2C_RX_INT);

      while (1);             

    此致、

    uint8 TX_PACK[bsize]={'H'、'E'、'R'、'C'、'U'、'L'、'E'、'S'、'M'、'I'、'C'、'R'、'O'、'-'、'T'、'I'};
    uint8 RX_PACK[bsize]={0};
    uint32数据;
     
    void main (void)
       uint32 buf_size = bsize;
       uint8 * t_buff =&TX_Pack[0];
       uint8 * r_buff =&RX_Pack[0];
       _enable_interrupt_();
       i2cInit();                       
       i2cSetOwnAdd (i2cREG1、Own_add);  
       i2cEnableLoopback (i2cREG1);     
       i2c 接收器(i2cREG1、16、r_buff);
       i2cSetStart (i2cREG1);
       while (buf_size--)
       {
          i2cSendByte (i2cREG1、* t_buy++);       
       }
       i2cClearSCD (i2cREG1);
       i2cDisableNotification (i2cREG1、I2C_RX_INT);
       while (1);                        
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好、Simon、

    请查看此主题以及随附的中断运行模式下 I2C 工作代码的最终确认答案。