楼主你好!
关于bus off的恢复方法,在User manual中是这么说的:
Mode bit '1' (present) and an Error Warning Interrupt is generated, if enabled. Afterwards the Transmit Error Counter is set to '127', and
the Receive Error Counter is cleared. It will stay in this mode until the CPU clears the Reset Mode bit. Once this is completed the CAN
Controller will wait the minimum protocol-defined time (128 occurrences of the Bus-Free signal) counting down the Transmit Error
Counter. After that, the Bus Status bit is cleared (Bus-On), the Error Status bit is set '0' (ok), the Error Counters are reset, and an Error
Warning Interrupt is generated, if enabled. Reading the TX Error Counter during this time gives information about the status of the
Bus-Off recovery.
按照上面的说明,应该是Transmit Error Counter 被置为了127, 这时候,人为清除RM(Reset mode)位, 然后CAN控制器等待128个bus free信号,发送错误计数器进行递减,然后总线状态位恢复,Error状态位为0, Error 计数器复位。
所以,我认为你可以试试:
LPC_CAN1->MOD &= fffffffe; // 清除RM位
然后使用while等待CANnGSR[TXERR]到0, 之后,再查看bus状态, Error状态。
但是有个前提,一般出现错误,和外部总线硬件也有关系,建议你先移除总线上其他的CAN节点,只留一个CAN调试器供测试,防止出现一种情况,实际上总线恢复了,但是由于总线上其他节点的原因,又导致该CAN节点进入的bus off状态。
楼主可以再参考我说的方法在你那边试下。
如果还有问题,欢迎继续交流!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------