Olivier Heriveaux

CAN initialisation on mcf5235evb ColdFire

Discussion created by Olivier Heriveaux on Nov 15, 2007
Latest reply on Nov 21, 2007 by Olivier Heriveaux
Hi,

I'm currently working on a ColdFire mcf5235evb. I asked for some help a few weeks ago but I did'nt get any response. I still have problems to make the CAN module working correctly. However I changed a lot of things in my code. I wanted first to activate loopback mode because I don't have another node yet on the bus.

After CAN initialisation procedure, I try to read the value of one buffer control word, to check if the code is 0b1000 (TX not ready), but I get 0b0000 which is strange. I have read the Datasheet many times and I don't find where the problem is. Here is my code:

    // Select clock
    MCF_CAN_CANMCR(CAN_SEL) |= MCF_CAN_CANCTRL_CLKSRC;  
    // Activate CAN module (after the clock selection)
    MCF_CAN_CANMCR(CAN_SEL) &= ~MCF_CAN_CANMCR_MDIS;

    // Timing configuration
    MCF_CAN_CANCTRL(CAN_SEL) = MCF_CAN_CANCTRL_PRESDIV(CAN_PRESCALER)
        | MCF_CAN_CANCTRL_RJW(0)
        | MCF_CAN_CANCTRL_PSEG1(2)
        | MCF_CAN_CANCTRL_PSEG2(2)
        | MCF_CAN_CANCTRL_CLKSRC
        | MCF_CAN_CANCTRL_LPB
        | MCF_CAN_CANCTRL_LBUF
        | MCF_CAN_CANCTRL_PROPSEG(0);

    // Buffers initialisation
    uint32 x = (0x08 << 24) // Code
        | (1 << 22) // Substitue remote request
        | (1 << 21) // Extended mode
        | (1 << 16); // Data length
    MCF_CAN_MBUF0_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF1_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF2_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF3_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF4_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF5_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF6_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF7_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF8_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF9_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF10_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF11_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF12_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF13_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF14_CTRL(CAN_SEL) = x;
    MCF_CAN_MBUF15_CTRL(CAN_SEL) = x;

    MCF_CAN_MBUF0_ID(CAN_SEL) = 1;
    MCF_CAN_MBUF1_ID(CAN_SEL) = 2;
    MCF_CAN_MBUF2_ID(CAN_SEL) = 3;
    MCF_CAN_MBUF3_ID(CAN_SEL) = 4;
    MCF_CAN_MBUF4_ID(CAN_SEL) = 5;
    MCF_CAN_MBUF5_ID(CAN_SEL) = 6;
    MCF_CAN_MBUF6_ID(CAN_SEL) = 7;
    MCF_CAN_MBUF7_ID(CAN_SEL) = 8;
    MCF_CAN_MBUF8_ID(CAN_SEL) = 9;
    MCF_CAN_MBUF9_ID(CAN_SEL) = 10;
    MCF_CAN_MBUF10_ID(CAN_SEL) = 11;
    MCF_CAN_MBUF11_ID(CAN_SEL) = 12;
    MCF_CAN_MBUF12_ID(CAN_SEL) = 13;
    MCF_CAN_MBUF13_ID(CAN_SEL) = 14;
    MCF_CAN_MBUF14_ID(CAN_SEL) = 15;
    MCF_CAN_MBUF15_ID(CAN_SEL) = 16;

    // RXGMASK0, RX14MASK0 and RX15MASK0
    // 0 = don't care
    MCF_CAN_RXGMASK(CAN_SEL) = 0x00000000;
    MCF_CAN_RX14MASK(CAN_SEL) = 0x00000000;
    MCF_CAN_RX15MASK(CAN_SEL) = 0x00000000;
   
    MCF_CAN_IMASK(CAN_SEL) = 0x00000000;
   
    // Leave freezemode
    MCF_CAN_CANMCR(CAN_SEL) &= ~MCF_CAN_CANMCR_HALT;

Another thing I don't understand: when I try to leave freeze mode, the HALT flag becomes 0 but the FRZ flag stays at 1 - FRZACK=0. ERRSTAT and ERRCOUNT stays at 0, only the flag IDLE is high. If anybody see something bad, please tell me ! Thanks for your help.

Olivier Heriveaux

Outcomes