I am trying to communicate between two LPC2129 microcontrollers, one as transmitter and the other as receiver, using interrupts to transmit and receive the message.
The transmit and receive interrupts are occurring in simulation, but the same is not working on the MCUs. But the other interrupts, like bus error and passive error are occurring.
And if I call the receive function in this ISR the message will receive once, and after that device is going to passive mode.
Issue: Even though I have separate ISRs for transmission and reception, it's not getting executed on the MCU, BUT the other CAN interrupt's ISR is executing.
The code is as follows please help.
CAN initialization:
PINSEL1 |= (DWORD) 0x00054000;
C2MOD = 1; // Enter Reset Mode
C2GSR = 0; // Clear status register
C2BTR = 0x001C001D; // Set bit timing
C2IER = 0x000007FF;
AFMR = 0x00000001; // Enable recieve acceptance filter
C2MOD = 0; // Enter normal operating mode
VICIntEnable |= 0x08280000; //Enable interrupts
VICVectCntl0 = 0x00000033; //Select a priority slot for a given interrupt
VICVectAddr0 = (unsigned)CAN2_ISR; //Pass the address of the IRQ
VICVectCntl1 = 0x0000003B; //Select a priority slot for a given interrupt
VICVectAddr1 = (unsigned)CAN2_Rx_ISR; //Pass the address of the IRQ
VICVectCntl2 = 0x00000035; //Select a priority slot for a given interrupt
VICVectAddr2 = (unsigned)CAN2_Tx_ISR; //Pass the address of the IRQ
AFMR = 0x00000001; //Disable the acceptance filters
Transmit function:
void Tx_Frame(unsigned int ID, unsigned long LSB_4, unsigned long MSB_4, unsigned char LEN, char RTR_FF)
{
while ( (C2SR & 0x00000004) != 0x00000004)
; // Checking that the TX buffer is empty
C2TFI1 |= (LEN << 16); // Frame information (RTR=0, 11 bit identifier. And length is setting)
C2TFI1 |= (RTR_FF << 30);
C2TDA1 = LSB_4; // Data A
C2TDB1 = MSB_4; // Data B
C2TID1 = ID; // 11 bit ID or 29 bit
C2CMR = 0x21; // Command: Transmit previously written message through TX buffer 1.
}
Receive function:
void Rx_Frame(void)
{
DWORD DATA_A,DATA_B,LEN,ID;
LEN = C2RFS;
ID = C2RID;
DATA_A = C2RDA;
DATA_B = C2RDB;
C2CMR = 0x04; // Release receive buffer command
}