This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F2812 ecan transmit receive interrupt ISSUE

Hello

My software needs to send and receive messages using interrupts.

I have used a sample found on this forum but it doesn't work.

 

Here is my code:

 

interrupt void ecan1intA_isr(void)
{
  unsigned int mailbox_nr;
 
    mailbox_nr = ECanaRegs.CANGIF1.bit.MIV1;

  if(mailbox_nr == 0)  // mailbox #1 receive message
  {     
//    GpioDataRegs.GPBDAT.all = ECanaMboxes.MBOX1.MDL.byte.BYTE0 & 0x000000FF;
//    ECanaShadow.CANRMP.bit.RMP1 = 1;
//    ECanaRegs.CANRMP.all = ECanaShadow.CANRMP.all;
   
    CTC_FetchRequest();
  }
 
  if(mailbox_nr == 5)  // mailbox #5 transmit-message
  {   
//    ECanaShadow.CANTA.all = 0;
//    ECanaShadow.CANTA.bit.TA5 = 1;
//    ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
     
    CTC_MASTER_ProcessVCUrequest();     
     
       CanMBox5Quit = 1;
  }
 
  PieCtrlRegs.PIEACK.bit.ACK9 = 1;
}

void main()

{

//
    LedInit();
   
// Initialize System Control registers, PLL, WatchDog, Clocks to default state:
// This function is found in the DSP28_SysCtrl.c file.       
    InitSysCtrl();

//    Enable Watchdog
    EALLOW;
      SysCtrlRegs.WDCR= 0x00AE;
      EDIS;
     
// Initialise the physical pins of the DSP
    Gpio_select();     
   
// Initialize Interrupt System PIE
    InitPieCtrl();
      InitPieVectTable();

// Overload CPU Timer 0 and CAN1 ISR - entry
      EALLOW;
      PieVectTable.TINT0 = &cpu_timer0_isr;
      PieVectTable.ECAN1INTA = &ecan1intA_isr;
      EDIS;

// Iitialize CPU - Timer system   
    InitCpuTimers();

    //
    InitECan(); // TODO: Le rescriem
   
    ///
    ConfigMailBox_0_RX(); // TODO: Le rescriem
   
// enable interrupt lines
    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;  // TINT0
    PieCtrlRegs.PIEIER9.bit.INTx6 = 1;  // ECAN1INTA
      IER |= 0x0101;
      EINT;   


// setup CPU-Timer 0 to 50 ms   
      ConfigCpuTimer(&CpuTimer0,150,50000);
      CpuTimer0.InterruptCount =0;
      CpuTimer0Regs.TCR.bit.TSS = 0;

 

while (1)

{

!!!(1)    if(CpuTimer0.InterruptCount >= 20)
    {
        CpuTimer0.InterruptCount = 0;
        if(CanMBox5Quit == 1)     // prev. transmission completed
        {
            CanMBox5Quit=0;
           
            //ECanaMboxes.MBOX5.MDL.byte.BYTE0 = send_data & 0x00FF;
   
            //ECanaShadow.CANTRS.bit.TRS5 = 1;
            //ECanaRegs.CANTRS = ECanaShadow.CANTRS;
   
            //send_data++;        // next payload
            //send_data %= 256;  // limit to 8 bit
           
            LedSwitch();
           
            GpioDataRegs.GPBTOGGLE.bit.GPIOB0 = 1;
        }
    }

}

 

}

 

!!!(1) - what is the utility of this condition and variable CpuTimer0.InterruptCount??

2 - the interrupt function "ECanaRegs.CANRMP.bit.RMP0" it never gets runed because i see the value of ECanaRegs.CANRMP.bit.RMP0 with my JTAG module and it is 1.

 

Thanks.

Regards.