MATLAB Answers

C2000 eCAN bus-off condition

10 views (last 30 days)
Donald
Donald on 4 Feb 2019
Edited: ashwinee jadhao on 25 Apr 2019
I am using the TI C2000 Simulink support package in 2018b. Occasionally in my environment the eCAN block detects errors (I assume TEC=128) and goes bus-off. Is there a way I can reset/clear this error without cycling power?
Thanks,
Don

Accepted Answer

Donald
Donald on 6 Feb 2019
I came up with something very similar, based on code in this post:
Declaration Code:
uint16_t ui16CANCTL;
Execution Code:
//Set the Auto-Bus-On bit in the CAN Control register to allow the CAN controller to recover from a bus-off event
//Read the high 16 bits of the 32bit register
ui16CANCTL = HWREGH(CANB_BASE + CAN_O_CTL);
//Write the high 16 bits OR'd with the ABO bit
HWREGH(CANB_BASE + CAN_O_CTL) = ui16CANCTL | CAN_CTL_ABO ;
//set timer to wait 0.1s before Bus-Off recovery sequence is started, $B71B0 should be 750000 clocks, which is 0.1s @ 7.5Mhz
HWREG(CANB_BASE + CAN_O_ABOTR) = 0x000B71B0;
//Do the same for the A CAN bus
ui16CANCTL = HWREGH(CANA_BASE + CAN_O_CTL);
HWREGH(CANA_BASE + CAN_O_CTL) = ui16CANCTL | CAN_CTL_ABO;
HWREG(CANA_BASE + CAN_O_ABOTR) = 0x000B71B0;
This code shows up near the end of "model_name".c in the folder "model_name" _ert_rtw in my setup.
I can now force a bus-off and it will recover.
Thanks for the help,
Don
  1 Comment
ashwinee jadhao
ashwinee jadhao on 25 Apr 2019
I have tried same solution but this is not solving my issue.
Here, file working on which is attached, please have a look
Thank you

Sign in to comment.

More Answers (4)

Venkatesh Chilapur
Venkatesh Chilapur on 5 Feb 2019
Hi,
We provide custom code blocks under simulink coder->custom code->System Initialize using which you may initialize the ABO bit in the CAN_CTL Register to enable the 'Auto-Bus-On' feature. This will help recover the CAN bus from a bus off state.
Regards,
Venkatesh Chilapur

Donald
Donald on 5 Feb 2019
That sounds like what I want to do. I found the System Initialize block in the library, but I don't know the syntax of how to add setting ABO in CAN_CTL to this block.
Is there a tutorial or something you can point me to?
Thanks,
Don

Venkatesh Chilapur
Venkatesh Chilapur on 6 Feb 2019
Hi,
Adding the below line of code should help!
HWREG(CANA_BASE + CAN_O_CTL) |= CAN_CTL_ABO;
Regards,
Venkatesh Chilapur

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!