KW38 CANFD Tx error with 64 Bytes payload

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KW38 CANFD Tx error with 64 Bytes payload

556 Views
rajparvez
Contributor I

I am using interrupt_transfer example of Flex CAN with

Nominal Baud Rate: 500 kbps
Data Baud Rate: 2 Mbps
Payload Size: 64 bytes
Peripheral Clock Frequency: 20 MHz

#define EXAMPLE_CAN CAN0
#define EXAMPLE_CAN_CLKSRC kCLOCK_BusClk
#define EXAMPLE_CAN_CLK_FREQ CLOCK_GetFreq(kCLOCK_BusClk)
#define RX_MESSAGE_BUFFER_NUM (6)
#define TX_MESSAGE_BUFFER_NUM (5)
#define USE_CANFD (1)
#define USE_IMPROVED_TIMING_CONFIG (1)
/*
* DWORD_IN_MB DLC BYTES_IN_MB Maximum MBs
* 2 8 kFLEXCAN_8BperMB 32
* 4 10 kFLEXCAN_16BperMB 21
* 8 13 kFLEXCAN_32BperMB 12
* 16 15 kFLEXCAN_64BperMB 7
*
* Dword in each message buffer, Length of data in bytes, Payload size must align,
* and the Message Buffers are limited corresponding to each payload configuration:
*/
#define DWORD_IN_MB (16)
#define DLC (15)
#define BYTES_IN_MB kFLEXCAN_64BperMB

flexcanConfig.baudRate = 500000U;
flexcanConfig.baudRateFD = 2000000U;
flexcanConfig.maxMbNum = 7;

 

/* Create FlexCAN handle structure and set call back function. */
FLEXCAN_TransferCreateHandle(EXAMPLE_CAN, &flexcanHandle, flexcan_callback, NULL);

FLEXCAN_SetRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true);

 frame.id     = FLEXCAN_ID_STD(txIdentifier);
 frame.format = kFLEXCAN_FrameFormatStandard;
 frame.type   = kFLEXCAN_FrameTypeData;
 frame.length = DLC;
 
for (i = 0; i < DWORD_IN_MB; i++)
{
frame.dataWord[i] = CAN_WORD0_DATA_BYTE_0(itr++) |
CAN_WORD0_DATA_BYTE_1(itr++) |
CAN_WORD0_DATA_BYTE_2(itr++) |
CAN_WORD0_DATA_BYTE_3(itr++);
}
            frame.brs = 1;
 
txXfer.mbIdx = TX_MESSAGE_BUFFER_NUM;
            txXfer.framefd = &frame;
            if(FLEXCAN_TransferFDSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &txXfer)!=kStatus_Success)
            {
            PRINTF("Error in Xmit!\r\n\r\n");
 
            }
            while (!txComplete)
            {
            };
 
Tx never gets completed. I have connected another board also with 12V Supply. I am keep in receiving interrupt of kFLEXCAN_TxWarningIntFlag flag and ending up in kFLEXCAN_BusOffIntFlag and kFLEXCAN_ErrorIntFlag. What could be the reason ? Above code is not compete I have just highlighted important part. I tried all different TX_MESSAGE_BUFFER_NUM and RX_MESSAGE_BUFFER_NUM. Nothing works. 
0 Kudos
Reply
1 Reply

475 Views
Ricardo_Zamora
NXP TechSupport
NXP TechSupport

Hello,

 

Hope you are doing well. Is the example working on your side without modifications?

 

Do you have some CAN captures?

 

Regards,

Ricardo

0 Kudos
Reply