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.

TMS320F280049: 你好,关于280049的CAN通讯例程

Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE

你好:

在280049的例程中,关于接收的例程中接收数据如下:

if((HWREG_BP(CANA_BASE + CAN_O_NDAT_21)) == 0x00000001)
{
//
// Get the received message
//
asm(" NOP");
CAN_readMessage(CANA_BASE, RX_MSG_OBJ_ID, rxMsgData);

rxMsgCount++;
// for(Toggle_ctr=0; Toggle_ctr<100; Toggle_ctr++)
// {
// GPIO_togglePin(65U);
// DEVICE_DELAY_US(100000);
// }
}

我对这个接收的理解就是只读取了CANA_BASE的RX_MSG_OBJ_ID收到的数据,并没有读取整个CAN_MSGOBJECT,例如 u32MsgID ,u32MsgIDMask,u32Flags;, u32MsgLen;数据就没有读取,

因为要根据u32MsgID 对数据进行区分,所以我想问一下,有没有读取整个CAN_MSGOBJECT的例程,多谢

  • 因为要根据u32MsgID 对数据进行区分

    您是只读取特定MsgID的数据?那您可以使用过滤的方式读取

    您可以参考 C:\ti\c2000\C2000Ware_3_04_00_00\driverlib\f2837xd\examples\cpu1\can 的 can_ex5_simple_receive

    和280049的CAN是相同的

  • u32MsgID 中不仅有协议号,还有这帧数据来着那个地址,因为有多个地址,所以使用的协议号过滤。

    过滤方法已经启用, 目前初步测试只收取对应的协议号没有问题,但是需要u32MsgID 中的信息来识别这帧数据来着那个地址,所以需要把整个CAN_MSGOBJECT都读取出来进行数据解析,并给对应的地址进行数据回复。

  • 但是需要u32MsgID 中的信息来识别这帧数据来着那个地址

    不知下面的函数是否符合您的要求

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    //*****************************************************************************
    //
    //! Reads the data and Message ID in a Message Object
    //!
    //! \param base is the base address of the CAN controller.
    //! \param objID is the object number to read (1-32).
    //! \param frameType is a pointer to the CAN_MsgFrameType to store the message
    //! type that has been received in the mailbox
    //! The \e frameType parameter shall be filled as of the following values:
    //! - \b CAN_MSG_FRAME_STD - Standard 11 bit identifier
    //! - \b CAN_MSG_FRAME_EXT - Extended 29 bit identifier
    //! This parameter is filled when return value is true for this function.
    //! \param msgID is a pointer to storage for the received Message ID
    //! Filled when the return value is true for this function.
    //! \param msgData is a pointer to the array to store the message data
    //! Filled with read Data when the return value is true for this function.
    //!
    //! This function is used to read the data contents and the Message ID
    //! of the specified message object in the CAN controller.The Message returned
    //! is stored in the \e msgID parameter and its type in \e frameType parameter.
    //! The data returned is stored in the \e msgData parameter.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    对于DCAN,Mailbox message-ID register 是在 CAN_IF1ARB 中的,您可以读取该寄存器获取

    Fullscreen
    1
    2
    3
    4
    5
    6
    struct CAN_IF1ARB_BITS { // bits description
    bp_32 ID:29; // 28:0 `
    bp_32 Dir:1; // 29 Message Direction
    bp_32 Xtd:1; // 30 Extended Identifier
    bp_32 MsgVal:1; // 31 Message Valid
    };
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 在更新到最新版本的C2000以后,已经找到CAN_readMessageWithID,目前正在调试,多谢。

    关于我们的项目,还有两个问题,目前我们这个项目是从28035迁移到280049,使用obj1,通过ID filter接收两个协议号的数据,obj4和obj5发送各自的协议号。

    在原来的逻辑中,通过收到数据触发第一帧恢复,剩下的存到缓存区,在主循环中通过判断ECanaRegs.CANTA.bit.TA5 = 1来判断第一帧发送完成,判断发送完成以后首先将该位清零,发送缓存中的数据,直到缓存中的数据发送完成。

    在DCAN的寄存器中就找打了CAN_ES.TxOk但是感觉这个无法区分两个obj,找到CAN_TXRQ_21.TxRqst,认为这个标识的是这个obj里面内容等待发送

    所以我想问ECanaRegs.CANTA.bit.TA5在DCAN中有对应的标志位吗?多谢。

    关于接收,之前通过ECanaRegs.CANRMP.bit.RMP1 = 1来判断有数据接收,有数据之后首先清除该标志位,然后读取寄存器中的数据。目前计划通过(HWREG_BP(CANA_BASE + CAN_O_NDAT_21))  == 0x00000001来进行数据接收的判断,CAN_readMessageWithID来读取寄存器数据。我觉得这两个判断的意义是一样的,但是在Table4-2 eCAN-DCAN Registers and Bit Equivalence中并没有找打这两个标志是等效的,所以我想问一下这两个数据是否等效,多谢

  • 目前我们这个项目是从28035迁移到280049

    这牵扯到从eCAN移植到DCAN,请您先看一下文档

    https://www.ti.com/lit/an/sprace5a/sprace5a.pdf 

    4.4 Migrating From eCAN

  • 已经查找过这个文档了,上文说的Table4-2 eCAN-DCAN Registers and Bit Equivalence就来自这个文档,但是这个文档仍然没办法解释我的两个疑问。