Problems reseting FlexCan

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems reseting FlexCan

1,051 Views
izzz
Contributor I

Hello,

I'm working with uTasker and MCF52235 microcontroller and I have problems when I try to SoftReset FlexCAN.

When I try to send/receive CAN messages, CAN_OTHER_INTERRUPT in uTasker is awaken. When that happens I try to reset FlexCAN, but often an unhandled exception (0x40602000) occurs when doing so the program enter in the while(1) defined inside de handler undef_int(void) in M5223X.c and stands there forever.

All the CAN interrupts are initialized (_CAN_buf_Interrupt0 to 15, _CAN_bus_off_Interrupt and _CAN_error_Interrupt) so every one has a handler.

I'm having problems when I use long cables between two boards communicated by CAN bus. I have the termination resistors at the end and at the begin of the cables.

This is my SoftReset FlexCAN code:

void fnResetCAN(void){
    unsigned int counter;
    if (CAN_ERRSTAT & (CAN_BUS_IDLE|CAN_ERROR_PASSIVE)){
    unsigned int imask = CAN_IMASK;
    unsigned int canmcr = CANMCR;
        CANMCR |= CAN_SOFTRST;
        for (counter=0; counter<500, (CANMCR & CAN_SOFTRST);counter++){}
          CAN_IMASK = imask;
       CANMCR |= canmcr;
       CANMCR &= ~(CAN_FRZ | CAN_HALT);

    }
}

Hope you can help me,

Ivan

Labels (1)
0 Kudos
1 Reply

390 Views
mjbcswitzerland
Specialist V

Hi Ivan

I would first try solving the problem that you are having when performing a soft reset.
Also an exception error will result in the undefined interrupt being called (this is more likely than an undefined interrupt from a peripheral source).

Follow the instructions here to try to identify the code that is causing this:
http://www.utasker.com/forum/index.php?topic=123.msg468#msg468

 

 

Generally only the CAN_ACK_ERROR (either CAN_TX_REMOTE_ERROR or CAN_TX_ERROR) are expected during normal operation when a destination doesn't respond. Other error sources are (BIT1ERROR | BIT0ERROR | CAN_CRC_ERR | CAN_FRM_ERR | CAN_STF_ERR), which generate the warning error event that is occuring. You can identify the actual error in more detal if you look at the variable ulError (copied from CAN_ERRSTAT) when the event is generated (in the _CAN_error_Interrupt() interrupt handler) - this may help identify the source of unreliabilities.

 

 

Regards

Mark

 

www.uTasker.com

0 Kudos