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.

can in stm=0 mode

I'm using can in stm=0 mode and transmitting 3 mailboxes with tpl bit same for all the three mail boxes (3,4,5)as follows:

void canComm(void)
{
    EALLOW;
       
   
        transmit();
    
}
    
 void transmit(void)
 
 {   
             
     
                  if(Page6.loop==0x0000)
             {
                    ECanaMboxes.MBOX3.MSGCTRL.bit.TPL = 1;
                   ECanaMboxes.MBOX4.MSGCTRL.bit.TPL = 1;
                   ECanaMboxes.MBOX5.MSGCTRL.bit.TPL = 1 ;          
                   transmitmb_3();
                   transmitmb_4();
                   transmitmb_5();
                   Page1.pg1temp1=0x7fff;
            }
            else
            {
            if(Page6.loop==0x0001)
            {
            Page6.loop=0x0002;
            }
            else
            {
                if(Page6.loop==0x0002)
                {
                    Page6.loop=0x0003;
                }
                else
                {
                    if(Page6.loop==0x0003)    
                    {
                        Page6.loop=0x0004;
                    }
                    else
                    {
                        if(Page6.loop==0x0004)
                        {
                            if(ECanaRegs.CANTA.bit.TA5==1&&ECanaRegs.CANTA.bit.TA3==1&&ECanaRegs.CANTA.bit.TA4==1 )
                             {
                                 Page6.loop=0x0000;
                                 Page1.pg1temp1=0x1fff;
                                  ECanaShadow.CANTA.all = 0xFFFFFFFF;     
                                 ECanaRegs.CANTA.all = ECanaShadow.CANTA.all;
                             }
                        }
                    }
                }
            }
          }
          
 }
             //}           
               //else
//               {
//                   if(Page6.loop==0x0001)
//                   {
//                       ECanaMboxes.MBOX3.MSGCTRL.BIT.TLP = 2;
//                       ECanaMboxes.MBOX6.MSGCTRL.BIT.TLP = 2;
//                       ECanaMboxes.MBOX5.MSGCTRL.BIT.TLP = 2 ;          
//                       transmitmb_3();
//                       transmitmb_5();
//                       transmitmb_6();
//                   }          
//            else
//               {
//                   if(Page6.loop==0x0001)
//                   {
//                       ECanaMboxes.MBOX3.MSGCTRL.BIT.TLP = 3;
//                       ECanaMboxes.MBOX7.MSGCTRL.BIT.TLP = 3;
//                       ECanaMboxes.MBOX5.MSGCTRL.BIT.TLP = 3 ;          
//                       transmitmb_3();
//                       transmitmb_5();
//                       transmitmb_7();      
//                   }    
//            else
//               {
//                   if(Page6.loop==0x0001)
//                   {        
//                     ECanaMboxes.MBOX3.MSGCTRL.BIT.TLP = 4;
//                       ECanaMboxes.MBOX5.MSGCTRL.BIT.TLP = 4 ;          
//                       transmitmb_3();
//                    transmitmb_5();      
//                   }
//               }
//               }
//               }          
/* Transmit from Mailbox 0. We need to use the following instructions for transmission.
TRS bit clears and TA bit sets for the corresponding mailbox after the message has been
sent from it. For self test mode, a mailbox generates its own acknowledgement bit.
We need to make use of the CANRMP register when not using self test mode for
reception. Also, the routine is almost similar for each mailbox. A loop maybe used.
 */
      
      
 
              void transmitmb_3(void)
              {
                //Page1.pg1temp1=0x1fff;        
                ECanaShadow.CANTRS.all = 0;     
             ECanaShadow.CANTRS.bit.TRS3 = 1;       
             ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
             Page6.loop=0x0001;
             }
              
              void transmitmb_4(void)
              {
                //Page1.pg1temp1=0x3fff;    
                 ECanaShadow.CANTRS.all = 0;     
              ECanaShadow.CANTRS.bit.TRS4 = 1;       
              ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
            }
              
              void transmitmb_5(void)
              {
                  //Page1.pg1temp1=0x7fff;    
                 ECanaShadow.CANTRS.all = 0;     
                 ECanaShadow.CANTRS.bit.TRS5 = 1;       
                 ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
                
            }
             
             void transmitmb_6(void)
              {
                  Page1.pg1temp1=0x07ff;        
                 ECanaShadow.CANTRS.all = 0;     
                 ECanaShadow.CANTRS.bit.TRS6 = 1;       
                 ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
                
            }
            
            void transmitmb_7(void)
              {
                  Page1.pg1temp1=0x07ff;        
                 ECanaShadow.CANTRS.all = 0;     
                 ECanaShadow.CANTRS.bit.TRS7 = 1;       
                 ECanaRegs.CANTRS.all = ECanaShadow.CANTRS.all;
                
            }
 
                        
        on the other module i am receiving as follows:

 void receive(void)
 
 {
         
    
 if(ECanaRegs.CANRMP.bit.RMP19==1)
 {
         ledAddress=0x00aa;
        Page1.pg1temp2=0x7fff;
}
  if(ECanaRegs.CANRMP.bit.RMP20==1)
       {
       ledAddress=0x00fe;
       Page1.pg1temp2=0x3fff;
    }  
           if(ECanaRegs.CANRMP.bit.RMP21==1)
           {
               ledAddress=0x00ff;
               Page1.pg1temp2=0x1fff;
           }
        if(ECanaRegs.CANRMP.bit.RMP21==1&&ECanaRegs.CANRMP.bit.RMP20==1&&ECanaRegs.CANRMP.bit.RMP19==1)
           {
               Page1.pg1temp2=0x0fff;
               
               ECanaShadow.CANRMP.all=0xFFFFFFFF;
            ECanaRegs.CANRMP.all=ECanaShadow.CANRMP.all;
           }  
  }

problem is that i'm  only receiving mailbox 5 

also tell me that whether the highlighted part is correct or not

help me with this problem its urgent

               

  • Hi Anuj,

    Some more clarity on message id's are required. From what i understand 

    MBox19 is configured to receive MBox3

    MBox20 is configured to receive MBox4

    MBox21 is configured to receive MBox5

    Have the corresponding msg ids been configured correctly? Are you transmitting extended or standard frames? And also be careful that two transmit mailboxes should not have same msg id.

    Vivek