Ivan Zambrana

Problems reseting FlexCan

Discussion created by Ivan Zambrana on Mar 31, 2010
Latest reply on Mar 31, 2010 by Mark Butcher


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;
    unsigned int imask = CAN_IMASK;
    unsigned int canmcr = CANMCR;
        for (counter=0; counter<500, (CANMCR & CAN_SOFTRST);counter++){}
          CAN_IMASK = imask;
       CANMCR |= canmcr;
       CANMCR &= ~(CAN_FRZ | CAN_HALT);


Hope you can help me,