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