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.

[参考译文] TMS320F28.0025万C:CAN -什么是比特率,我可以禁用自动重新传输吗?

Guru**** 2462890 points


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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1089537/tms320f280025c-can---what-is-the-bitrate-and-can-i-disable-the-auto-retransmit

部件号:TMS320F28.0025万C

您好,

我正在使用带有 TMS320F28.0025万C控制器的评估板来进行一些电机控制,目前为止它的工作非常出色。 现在我想使用CAN,但我遇到了一些问题。 我将开关S4设置为较低的设置,我看到CANL和CANH正常工作。 现在我连接了一个CAN设备(在另一个系统中的Testen,它已经工作多年),我每秒发送一条CAN消息。 我为CAN实施了中断ISR计数器,但发送消息时从未触发。 此外,TI控制器似乎自动重新发送任何消息,这是正常的,但当我尝试设置连接时,有些东西不适合我,这是不实际的。

因此,我首先关注的是比特率,在初始化过程中实施了以下内容:

// Set up the CAN bus bit rate to 200kHz
    // Refer to the Driver Library User Guide for information on how to set
    // tighter timing control. Additionally, consult the device data sheet
    // for more information about the CAN module clocking.
    CAN_setBitRate(obj->canHandle, DEVICE_SYSCLK_FREQ, 500000, 16);

在注释中,这是200kHz比特率,但多少选择了500波特,为什么?

是否有办法停用自动重新传输,使其只发送和忘记? 否则,它会锁定CAN总线。

编辑:我发送的CAN帧类似于(速度参考为100Hz)。 我还看到 canComVars.errorFlag始终为==1。 因此 ,can_getStatus(halHandle->canHandle)似乎总是给出错误。

	txFrame.rtr = 0;
	txFrame.extended = false;
	txFrame.id = 0x001;
	txFrame.length = 8;
	txFrame.data.uint8[0] = 0x00;
	txFrame.data.uint8[1] = 0x00;
	txFrame.data.uint8[2] = 0x03;
	txFrame.data.uint8[3] = 0xE8;
	txFrame.data.uint8[4] = 0x00;
	txFrame.data.uint8[5] = 0x00;
	txFrame.data.uint8[6] = 0x00;
	txFrame.data.uint8[7] = 0x00;

Edit2:我的进一步调查显示,CAN中断始终由控制器状态中断触发:

    // If the cause is a controller status interrupt, then get the status
    if(status == CAN_INT_INT0ID_STATUS)
    {
        //
        // Read the controller status.  This will return a field of status
        // error bits that can indicate various errors.  Error processing
        // is not done in this example for simplicity.  Refer to the
        // API documentation for details about the error status bits.
        // The act of reading this status will clear the interrupt.
        status = CAN_getStatus(halHandle->canHandle);
        canComVars.status = status;

        // Check to see if an error occurred.
        if(((status  & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 7) &&
           ((status  & ~(CAN_STATUS_TXOK | CAN_STATUS_RXOK)) != 0))
        {
            // Set a flag to indicate some errors may have occurred.
            canComVars.errorFlag = 1;
        }

    }

我读回的状态值为99 = 0b110.0011万。 这意味着CAN_ES寄存器中的以下寄存器较高:

LEC位0和1表示 材料错误和表单错误。 第5位和第6位表示EPass和EWarn,因此控制器会进入钝化状态。 但我真的不知道该如何处理这些错误。 它们可在网站2134的参考手册中找到,网址 为:www.ti.com/.../spruin7a.pdf

Edit3:将BitTime更改为10后,似乎至少停止向CANBus发送垃圾邮件。 现在的问题是,当我发送消息时,它总是得到 CAN_INT_INT0ID_STATUS中断,而不是 RX_MSG_OBJ_ID。  CAN_ES 为16,因此Rx指示工作。 但中断状态错误。

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

    您好,

    感谢您的提问! 我将在审核请求后的一周结束前提供初步回复。
    此致,

    文斯

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

    在正确的比特时间和正确的消息之后,它现在可以工作