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.

TMS320F28377S: 主从机两个DSP CAN通信问题求助

Part Number: TMS320F28377S

问题描述:。

主从机均为TMS320F28377S,通过CAN通信交互数据,波特率500kHz。

主机每1ms发送一帧数据给从机,长度5个字节。

从机采用中断方式接收主机数据,开始一段时间接收正常,过一段时间后,从机接收不到主机的数据,间隔时间不固定,有时很长时间也没有接收不到的现象。

另:从机接收不到主机数据现象发生后,通过Can工具给从机DSP发送其他帧ID数据,从机还能成功接收。

请问:

该现象是怎么产生的?应该如何解决呢?

  • 有单步调过吗?主从机的程序分别停在哪里?

  • 没有,逆变器跑的大功率。主机的数据还在发送,通过CANTest工具可以看到,从机接收不到了。

  •  从机接收不到主机的数据时,从机程序也没进入上面CAN通信错误中断中。会是因为我程序还有个1ms中断,把CAN接收中断影响了吗?

  • 总结一下就是,异常发生时,主机还可以发送该帧ID的数据,从机还可以接收其它帧ID的数据。

    另:从机接收不到主机数据现象发生后,通过Can工具给从机DSP发送其他帧ID数据,从机还能成功接收。

    如果用Can工具给从机发送该帧ID的数据,从机能接收到吗?

    会是因为我程序还有个1ms中断,把CAN接收中断影响了吗?

    这个是什么中断?

  • (1)如果用Can工具给从机发送该帧ID的数据,从机能接收到吗?

    ==== 从机也接收不到。

    (2)这个是什么中断?

    ==== 这个是定时器中断,用来处理其他任务的,1ms中断中程序的执行时间测试最长有70us。

  • 有检查过中间的连接正常吗?

    可以分享下can的配置吗?

  • (1)有检查过中间的连接正常吗?

    ==== 中间连接是正常的。

    (2)can的相关配置如下:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    // ====================================================================
    // === 1. ============================================
    // ====================================================================
    void main(void)
    {
    //
    // Initialize the CAN controllers
    //
    CANInit(CANA_BASE);
    //
    // Setup CAN to be clocked off the PLL output clock
    //
    CANClkSourceSelect(CANA_BASE, 0);
    //
    // Set up the CAN bus bit rate to 500kHz for each module
    // This function sets up the CAN bus timing for a nominal configuration.
    // You can achieve more control over the CAN bus timing by using the
    // function CANBitTimingSet() instead of this one, if needed.
    // Additionally, consult the device data sheet for more information about
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • What could be happening is that the interrupts are not being serviced promptly leading to the impression that messages are being lost.

    ===== 什么会导致中断程序没有被及时服务呢?

    If masking is not used and the message object is retaining the correct MSGID (ARBID), it will receive a transmitted message. It cannot suddenly stop receiving messages.

    ===== 程序中掩码没有用,MSGID (ARBID)也没有更改。

    怎么去进一步定位到问题呢?

  • 好的,我跟进过去了

  • 麻烦再帮忙问一下:

    If a message was indeed over-written (because it was not read in time by the software), this bit would be set.

    ===== 消息被重写丢失后,出错的消息对象会一直收不到数据吗?

    The application could either configure more message objects for receive or otherwise ensure that CAN interrupts are serviced on time.

    ===== 我可以使用两个不同的消息对象接收同一个ID的数据吗?

    谢谢!

  • No, the fact that a message was overwritten before being read should not prevent that message object from receiving future messages.

    Only if the message objects are part of a FIFO. 

    ===== 我现在是出问题的消息对象再也接收不到消息了。我能通过配置成FIFO接收模式解决吗?如果可以的话,麻烦给下配置成FIFO接收模式的例程。谢谢。

  • Please have customer check the MsgLst (Receive Message Lost) bit for the suspected message object. If a message was indeed over-written (because it was not read in time by the software), this bit would be set. 

    ===== 我按以下方法检查MsgLst位,发现从机接收不到主机数据时,从机出错消息对象的MsgLst没有被置位。

    if( (sRXCANMsgDspComm05.ui32Flags & MSG_OBJ_DATA_LOST) == 1)
    {
    systemFault.bit.DebugFault = 1;    // Send to the upper computer for observation
    }

    我还能做哪些调试?

  • 感觉这个CAN内核只从早期F280x、F2803x改进后问题不少,我在F280025上遇到不使能Mask,MaskID全设为0的情况下都只能接收到邮箱预设ID(通过SysCfg配置)的数据帧,其他ID的数据帧无法接收到。感觉还是原来那种消息RAM直接映射的方式比较好,连上仿真器每个邮箱的设置和状态一目了然。

  • 你描述的是正常的吧。是要使能Mask,MaskID全设为0,这个邮箱才能接收到所有帧的数据吧。

  • 使能Mask后MID中 bit=1需要匹配,bit=0 don‘t care,

    不使能Mask不是应该接收所有帧吗?我理解错了??

  • “使能Mask后MID中 bit=1需要匹配,bit=0 don‘t care。”

    ===== 这个我理解是对的。

    不使能Mask就要完全匹配帧ID才能接收。使能了Mask,设置的MaskID才有用。你可以试试。

  • OK,我试试。找到了文档里面相关部分(下图),既然UMask=0不再过滤,一般理解应该是接收所有消息才对。

  • 这个函数的注释。

  • 好的,跟进过去了~

  • 已经解决了,需要设置UMask=1以及Msk ID=0才能接收所有数据帧

  • 问题解决就好~也感谢分享解决方案