Frames not Transmitted and Received via CAN - KEAZ128A

cancel
Showing results for 
Search instead for 
Did you mean: 

Frames not Transmitted and Received via CAN - KEAZ128A

213 Views
Contributor I

Hi,

I am working with CW along with PE for KEAZ128A as target micro controller, which has MSCAN Module. I want to send a frame, receive a frame and send a RESPONSE Frame for UDS protocol (refer image1) Via CAN bus irrespective of CAN IDs(Assuming single client-single server configuration). It is configured in loopback mode for testing purpose. But, my controller transmits the frame perfectly and is not receiving and sending back Response as intended.Also, It is not sending frames in EXTENDED ID(29 Bit). My baud rate is 500 and MSCAN is configured via CAN1 LDD component (refer image 2).i4.png

                                                      Image 1 -- Frames to be sent and Received

Capture2.PNG

                                                                     Image 2 --- CAN1 LDD Component settings

My queries are:

1. How to configure CAN1OnFreeTxBuffer and CAN1OnFullRxBuffer events from CAN1 LDD Component in order to make frames send and receive for this Client-Server model?

2. How to make Extended CAN ID frames to transmit and receive? (I have Tried as given in Typical usages example by OR masking LDD_CAN_MESSAGE_ID_EXT)

3. Is there any Interrupt service workaround like Event driven approach to be implemented for this particular criteria?

Thanks and Regards,

S. Anandharaman

0 Kudos
3 Replies

51 Views
NXP TechSupport
NXP TechSupport

Hi Anand,

Check my answer bellow:

1. How to configure CAN1OnFreeTxBuffer and CAN1OnFullRxBuffer events from CAN1 LDD Component in order to make frames send and receive for this Client-Server model?

In the Event tab in PE check that the value in the event is in "generate code":

pastedImage_1.png

2. How to make Extended CAN ID frames to transmit and receive? (I have Tried as given in Typical usages example by OR masking LDD_CAN_MESSAGE_ID_EXT)

This is the example that is in the typical usage. Only be sure that the IDBuffer is the one for transmit, in your case is 1.

MyCANPtr = CAN1_Init(NULL); 

Frame.MessageID = (0x123456U | LDD_CAN_MESSAGE_ID_EXT); /* Set Tx ID value - extended */ 
Frame.FrameType = LDD_CAN_DATA_FRAME; /* Specyfying type of Tx frame - Data frame */
Frame.Length = sizeof(OutData); /* Set number of bytes in data frame - 4B */
Frame.Data = OutData; /* Set pointer to OutData buffer */
DataFrameTxFlg = FALSE; /* Clear DataFrameTxFlg */
Error = CAN1_SendFrame(MyCANPtr, 1U, &Frame); /* Sends the data frame over buffer 1 */ 
while (!DataFrameTxFlg) { /* Wait until data frame is transmitted */
}‍‍‍‍‍‍‍‍‍‍

You can check if this is send correctly putting breakpoints in the ISR.

3. Is there any Interrupt service workaround like Event driven approach to be implemented for this particular criteria?

If you check in the CAN code generated, the events CAN1OnFreeTxBuffer and CAN1OnFullRxBuffer are called in the interrupt. You could check this at the code last section. in the CAN1.c.

Best Regards,

Alexis Andalon

0 Kudos

51 Views
Contributor I

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.

0 Kudos

51 Views
NXP TechSupport
NXP TechSupport

Hello S.Anandharaman,

 

As far as I could see the problem, the receiving device in not responding and the CAN protocol has the featured that will retry sending the information until an acknowledge from the receiving device.

 

I will suggest to use the loopback mode first to ensure the configurations were done correctly and ensure the correctly module behavior.

 

Best Regards,

Alexis Andalon

0 Kudos