Actually, I have already configured both CAN1 On Free Tx Buffer and CAN 1 On Full Rx Buffer to "generate code" in PE Window. My question is, after I build and debug the code, my program still transmits the first frame without stopping. The second frame data is not transmitted at all.
This is my understanding:
1. I am transmitting Frame1 with Data 1(8B)
2. After free Tx Buffer, Tx Interrupt arrises on PEISR.
3. It invokes CAN1OnFreeTxBuffer() event under Event.c
4. I am just triggering a flag there and returns to main code, where it calls.
5. Now, again, I am transmitting next frame with different data (Frame2 with Data 2(8B))
6. Steps 2, 3 and 4 are repeated.
7. Program just restarts since, it is written in for(;;)
Here is my main procedure sequence on "MyCAN.c" for above mentioned steps of 1 to 6.
void dataunit() //----> describing data unit of can message
{
TXFrame.MessageID = (0x123456U | LDD_CAN_MESSAGE_ID_EXT); /* Set Tx ID value - extended */
TXFrame.FrameType = LDD_CAN_DATA_FRAME; /* Specyfying type of Tx frame - Data frame */
TXFrame.Length = 8; /* Set number of bytes in data frame - 8B */
}
void transmit1() //------> transmitting first frame
{
dataunit();
TXFrame.Data = OutData1; /* Set pointer to OutData buffer */
TxFlg = FALSE; /* Clear DataFrameTxFlg */
Error = CAN1_SendFrame(MyCANPtr, 1U, &TXFrame); /* Sends the data frame over buffer 1 */
while (!TxFlg) { /* Wait until data frame is transmitted */
}
}
void transmit2() //------> transmitting second frame
{
dataunit();
TXFrame.Data = OutData2; /* Set pointer to OutData buffer */
TxFlg = FALSE; /* Clear DataFrameTxFlg */
Error = CAN1_SendFrame(MyCANPtr, 1U, &TXFrame); /* Sends the data frame over buffer 1 */
while (!TxFlg) { /* Wait until data frame is transmitted */
}
}The content of CAN1OnFreeTxBuffer under "Events.c" is:
void CAN1_OnFreeTxBuffer(LDD_TUserData *UserDataPtr, LDD_CAN_TMBIndex BufferIdx)
{
TxFlg = TRUE;
}
If I am correct or doing anything wrong here? As you mentioned, ISR is properly working and I have checked CAN1.c in Generated code as you mentioned.
Thanks and Regards,
S.Anandharaman.