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.

TCAN4550: MCU端如何接收TCAN4550收到的CAN报文更合适?

Part Number: TCAN4550

TCAN4550 nINT中断到M3连接如上图所示。

M3想尽快收到CAN总线上的报文,以减少TCAN4550转换带来的通信延迟。

1、这里想通过nINT中断方式通知M3,当有外部中断来的时候,在M3的外部中断中进行接收消息标志位检测,,如果有消息,则读取CAN消息放至本地的接收队列中;直到TCAN4550的接收队列为空,退出接收及接收中断。

但是通过M3的手册得知,TCAN4550的nINT中断是很多中断信号的或,,只要有任何中断来,都会引起nINT引脚由高到低(如果原来是低电平,会维持低电平);我已经在该外部中断中清除了所有中断,,还是会引起该中断信号一直是低电平,,不知道是不能通过该方式接收消息,还是我清除中断的方式不对。如果不对,,有没有参考的调用清除中断的调用及传参可以提供??

2、我看DEMO中给出接收CAN消息是通过查询方式,因为我的TCAN4550任务是周期性的,,如果查询方式,最大会有一个任务周期的消息接收延时,,所以不倾向于查询方式接收CAN消息。

3、还有没有更好的接收方式可以提供?

期待回复!

  • Hello Nicolas,

    The nINT pin is the Global Interrupt pin that is used to reflect any enabled interrupt bit set at the device and CAN levels.  Device level interrupts include events such as SPI communication errors, over-voltage or under-voltage, and over-temperature conditions, etc. CAN level interrupts would include all CAN related interrupts inside the MCAN module including new messages. 

    The TCAN4550 uses the Bosch MCAN IP for the CAN Controller and there are two dedicated MCAN Interrupt lines that can be used to isolate specific interrupts of importance.  The GPIO1 and GPO2 pins can be configured to reflect these two MCAN interrupt lines allowing you to use them as additional hardware interrupt pins that can be prioritized in your MCU's ISR.  The new RX Message interrupt bit could be assigned to either the GPIO1 or GPO2 pins by itself so that it would only indicate a new message has arrived.

    Because the nINT pin is the Global interrupt pin, it will also reflect the new message has arrived, but as you have indicated other events could be set to keep the line low as well.  You can disable any device level interrupt bits you do not care about in register 0x0830.

    The MCAN interrupts are enabled in register 0x1054 and can be assigned to one of the two MCAN Interrupt lines in register 0x1054.  You can enable the MCAN Interrupt Lines in register 0x105C.

    If you want to use the GPIO1 pin for an MCAN Interrupt line, make sure that the GPIO1_GPO_CONFIG bits are set to "01" to enable the MCAN_INT_1 line (0x0800[11:10]=2'b01) which is the default value for this register..

    If you want to use the GPO2 pin for an MCAN Interrupt line, make sure that the GPO2_CONFIG bits are set to "01" to enable the MCAN_INT_0 line (0x0800[23:22]=2'b01) which is not the default value for this register.

    Regards,

    Jonathan

  • 我在nINTl输入至M3的外部中断服务函数中已经清除了所有中断,伪代码如下TCAN4x5x_MCAN_Interrupts mcan_ir

    mcan_ir.word = 0xFFFFFFFF;
    TCAN4x5x_MCAN_ClearInterrupts(&mcan_ir);

    按理上来说清除所有故障标志后,TCAN4550的nINT信号会拉高,,但实际仍然为低。。是我清除的方法不对?还是需要清除别的寄存器???

    目前还是倾向于通过nINT中断接收CAN消息。

  • Hello Nicolas,

    The nINT pin is the logical OR of all bits in registers 0x0820 and 0x0824 that are not masked and in order to release the nINT pin from the active low state, you may need to clear bits in multiple registers.

    Register 0x0820 contains the device related interrupts not specific to CAN messages.

    Register 0x0824 is a read-only copy of register 0x1050 and contains the CAN related interrupts from the MCAN controller.  To clear any MCAN interrupts, they must be cleared by writing to the 0x1050 register and not the 0x0824 read-only register.  Register 0x0824 is included right next to register 0x0820 so that both interrupt registers can be read in a single 2-word SPI Read transaction with Length field set to 2 which is more efficient than two separate reads to registers 0x0820 and 0x1050.

    If the SPIERR bit is set in register 0x0820, then there are bits set in the Status register 0x000C that would need to be cleared by writing to register 0x000C.

    It looks like you may be clearing the MCAN interrupts in register 0x0824 and 0x01050, but you may not be clearing the other device related interrupts reflected in register 0x0800 and 0x000C if there is a SPI error.  Can you verify that all registers are cleared and then check the nINT pin?

    Regards,

    Jonathan