AnsweredAssumed Answered

MPC5604B CAN RX Interrupt

Question asked by jo young dae on Aug 8, 2016
Latest reply on Aug 8, 2016 by Petr Stancik

I dont know why dont occur RX Can interrupt

please review the code

 

(configuration function)

void InitCAN_0 (void) 
{
    uint8_t   i;

    CAN_0.MCR.R = 0x5000003F;       /* Put in Freeze Mode & enable all 64 msg bufs */
    CAN_0.CR.R = 0x01490082;        /* Configure for 8MHz OSC, 500KHz bit time */
    for (i=0; i<64; i++)
    {
        CAN_0.BUF[i].CS.B.CODE = 0; /* Inactivate all message buffers */
    }
    CAN_0.BUF[8].CS.B.CODE = 8;     /* Message Buffer 0 set to TX INACTIVE */
CAN_0.BUF[9].CS.B.CODE = 8;     /* Message Buffer 0 set to TX INACTIVE */

CAN_0.BUF[0].CS.B.IDE = 0;      /* MB 4 will look for a standard ID */
    CAN_0.BUF[0].ID.B.STD_ID = 0x154; /* MB 4 will look for ID = 555 */
CAN_0.BUF[0].CS.B.CODE = 4;     /* Message Buffer 0 set to RX INACTIVE */
CAN_0.RXGMASK.R = 0x1FFFFFFF;   /* Global acceptance mask */
    SIU.PCR[16].R = 0x0624;         /* MPC56xxB: Config port B0 as CAN0TX, open drain */
    SIU.PCR[17].R = 0x0100;         /* MPC56xxB: Configure port B1 as CAN0RX */
    CAN_0.MCR.R = 0x0000003F;       /* Negate FlexCAN 0 halt state for 64 MB */
/* CAN_0.IMRL.B.BUF01M = 1; */
CAN_0.IMRL.B.BUF00M = 1;
    INTC.PSR[68].R = 0x04;
}

 

(TX Function)

    CAN_0.BUF[8].CS.B.IDE = 0;      /* Use standard ID length */
    CAN_0.BUF[8].ID.B.STD_ID = 0x148; /* Transmit ID is 0x148 */

    CAN_0.BUF[8].CS.B.RTR = 0;      /* Data frame, not remote Tx request frame */
    CAN_0.BUF[8].CS.B.LENGTH = 8 ; /* # bytes to transmit w/o null */

    for (i=0; i<sizeof(TxData); i++)
    {
        CAN_0.BUF[8].DATA.B[i] = TxData[i]; /* Data to be transmitted */
    }

 

 

(RX Function)

while (CAN_0.IFRL.B.BUF00I == 0){};

    gRxCODE = CAN_0.BUF[0].CS.B.CODE;    /* Read CODE, ID, LENGTH, DATA, TIMESTAMP */

    gRxID = CAN_0.BUF[0].ID.B.STD_ID;

    gRxLENGTH = CAN_0.BUF[0].CS.B.LENGTH;

    for (j=0; j<gRxLENGTH; j++)

    {

        gRxDATA[j] = CAN_0.BUF[0].DATA.B[j];

    }

    gRxTIMESTAMP = CAN_0.BUF[0].CS.B.TIMESTAMP;

    dummy = CAN_0.TIMER.R;                /* Read TIMER to unlock message buffers */   

    CAN_0.IFRL.R = 0x00000001;            /* Clear CAN 0 MB 1flag */

 

interrupt means is vector table

 

#pragma section data_type ".intc_sw_isr_vector_table" ".intc_sw_isr_vector_table" data_mode=far_abs 

  uint32_t IntcIsrVectorTable[] = {    

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 00 - 04 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 05 - 09 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 10 - 14 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 15 - 19 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 20 - 24 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 25 - 29 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 30 - 34 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 35 - 39 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 40 - 44 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 45 - 49 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 50 - 54 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 55 - 59 */

/* Use the next line for MPC551x or MPC563x: */

/* (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy,*/ /* ISRs 60 - 64 */

/* Use the next line for MPC56xB, MPC56xxP, MPC56xS, where PIT1 vector number is 60: */

(uint32_t)&Pit1ISR, (uint32_t)&Dummy, (uint32_t)&ADCECHISR, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 60 - 64 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&CanISR1, (uint32_t)&Dummy, /* ISRs 65 - 69 */

(uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, (uint32_t)&Dummy, /* ISRs 70 - 74 */

 

(interrupt service routine function)

void CanISR1 (void)

{

    RecieveMsg();

}

Outcomes