Hi,
We are trying to send and receive CAN frame continuously but we observed the frames which is getting received is not the updated one ,as we see older frames . We suspect that MCAN data memory is holding the older frame and we are unable to find API which clears the MCAN data memory. We have used the sample code provide by you. Kindly guide us to find the API or the action needed to be taken to clear the MCAN older frame/data.
Below mentioned the sequence of action we are performing.
1. Transmit dummy Payload.
2. Receive payload.
3. Transmit the Received Payload.
Below is the code snippet we followed to receive and transmit in loop.
uint8
Receive_CANFD(uint8_t *dataPayload)
{
uint32_t readdata;
uint8_t numBytes = 0;
TCAN4x5x_Device_Interrupts dev_ir ; // Define a new Device IR object for device (non-CAN) interrupt checking
TCAN4x5x_MCAN_Interrupts mcan_ir ; // Setup a new MCAN IR object for easy interrupt checking
do{
TCAN4x5x_Device_ReadInterrupts(&dev_ir); // Read the device interrupt register
}while(dev_ir.M_CAN_INT != 1);
TCAN4x5x_Device_ClearInterrupts(&dev_ir);
do{
mcan_ir.RF0N = 0;
TCAN4x5x_MCAN_ReadInterrupts(&mcan_ir); // Read the interrupt register
}while(mcan_ir.RF0N != 1 ); //Wait for Receive Frame
if (mcan_ir.RF0N == 1 ) // If a new message in RX FIFO 0
{
TCAN4x5x_MCAN_RX_Header MsgHeader = {0}; // Initialize to 0 or you'll get garbage
numBytes = TCAN4x5x_MCAN_ReadNextFIFO( RXFIFO0, &MsgHeader, dataPayload); // This will read the next element in the RX FIFO 0
TCAN4x5x_MCAN_ClearInterruptsAll();
}
return numBytes;
}
/*Transmit API*/
void
Transmit_CANFD(TCAN4x5x_MCAN_TX_Header *header, uint8_t *dataPayload)
{
TCAN4x5x_MCAN_WriteTXBuffer(0, header, dataPayload);
TCAN4x5x_MCAN_TransmitBufferContents(0);
}
Attached snapshot for Reference.
In the above snapshot first byte of data we are updating and fourth byte is the no of frames.
Regards,
Kumar Ashutosh