Tool/software:
Dear TI,
i tried by generating bus off condition by shorting CANH and CANL signals,
I can confirm from register REG_MCAN_IR that CAN bus off condition occurs upon shorting CANH,CANL pins
bool_t TCAN4550_IsBusOff(void)
{
return (TCAN4x5x_ReadRegister(REG_MCAN_IR) & REG_BITS_MCAN_IR_BO) != 0U; // Check Bus-Off interrupt flag
}
when bus off condition is detected i used below code to recover from it, but bus never recovers from busoff conditiion and i am unable to transmit more messages
until i restart the tcan4550x from scratch
static inline void TCAN4550_BusRecoveryInit(void)
{
// Step 1: Clear the bus-off interrupt flag
// This writes to the MCAN Interrupt Register (IR) to clear the Bus-Off (BO) interrupt flag.
// Clearing this flag ensures that subsequent bus-off events can be detected by the controller.
TCAN4x5x_WriteRegister(REG_MCAN_IR, REG_BITS_MCAN_IR_BO);
// Step 2: Read the current value of the CCCR register
// The CAN Controller Configuration Register (CCCR) holds various control bits for the TCAN4550.
// Here, we read its current value to modify specific bits while preserving others.
uint32_t cccrValue = TCAN4x5x_ReadRegister(REG_MCAN_CCCR);
// Step 3: Clear the INIT bit in the CCCR value
// The INIT bit controls the initialization mode of the CAN controller.
// Clearing this bit allows the controller to exit initialization mode, starting the bus-off recovery sequence.
// The bitwise AND with the complement of REG_BITS_MCAN_CCCR_INIT ensures that only the INIT bit is cleared.
cccrValue &= ~REG_BITS_MCAN_CCCR_INIT;
// Step 4: Write the modified value back to CCCR to apply the change
// Writing this modified value back to the CCCR register takes the controller out of initialization mode.
// This initiates the bus-off recovery sequence, where the controller waits for 129 idle sequences on the CAN bus
// (each consisting of 11 consecutive recessive bits) before rejoining the bus.
TCAN4x5x_WriteRegister(REG_MCAN_CCCR, cccrValue);
}
It will be very much thankful if you can provide some suggestions for this