Hi,
I am using the experimenters kit to use CAN in self test mode. I have configured 6 transmit mailboxes (MB10-MB15) and 6 receive mailboxes (MB26-MB31) in eCAN mode and 11-bit identifier. I am also displaying this data on the terminal over SCI when the data is read (within the interrupt).
/*CAN0 Rx/Tx Interrupt Function*/ interrupt void ecan0intA_isr(void) { // // Data variables for transmission receive unsigned, signed (for BDC) // unsigned int mailbox_nr, u_data; int s_data; char d; mailbox_nr = ECanaRegs.CANGIF0.bit.MIV0; //mailbox that set GMIF0-I0EN ECanaShadow.CANTA.all = 0; //ECanaShadow.CANTRS.all = 0; //ECanaShadow.CANTRS.all = ECanaRegs.CANTRS.all; switch(mailbox_nr) { case(30): // if mailbox #30 receive message { // and prepare MBX1 for next receive ECanaRegs.CANRMP.bit.RMP30 = 1; // clear the status flag RMP1 u_data = ECanaMboxes.MBOX30.MDH.byte.BYTE5; switch(u_data) { case (0x20): d = 'P'; break; case (0x21): d = 'R'; break; case (0x22): d = 'N'; break; case (0x23): d = 'D'; break; default: d = 'D'; } // // load data // sprintf(str, "Drive mode is %c \n", d); msg = str; scia_msg(msg); break; } }
I am using interrupts to access the data. It works for the most part except when my RMP register is filled due to reception due to multiple mailboxes. In this case, the control goes the the highest priority (MB30 in this case). When I set the RMP bit to clear BIT30, the other bits are cleared as well and I lose the data from those MBs.
Is there something I am doing wrong? What can I do it fix this?
Thank you.