How set KW38 enter CANFD model?

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

How set KW38 enter CANFD model?

1,302 Views
leonordo
Contributor I

Why do I set the CANFD mode of KW38 according to the official routine, but still use the normal CAN mode to send data every time? Here is my code

 

Tags (1)
0 Kudos
Reply
5 Replies

1,299 Views
leonordo
Contributor I
hal_can_frame_t hal_can_frame;
flexcan_fd_frame_t CANFDframe;
flexcan_mb_transfer_t CANFDtxXfer;
flexcan_mb_transfer_t CANFDrxXfer;
 
int main(void)
{
hal_can_param_t param;
 
static uint8_t CANFDSendCount;
// memset(&CANFDframe,0,sizeof(flexcan_fd_frame_t));
 
uint8_t ebuff[10]={0x01,0x02,0x03,0x04,0x00,0x05,0x06,0x07,0x08,0x09};
    /* Initialize board hardware. */
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();
    //CAN过滤ID
 
    PRINTF("-------INT start-------");
//    }
    //init函数
#if 0
    HAL_CANInit(instance,&param);
#else
    FLEXCAN_GetDefaultConfig(&flexcanConfig);
    flexcanConfig.clksrc=kFLEXCAN_ClkSrcPeri;
    flexcan_timing_config_t timing_config;
    memset(&timing_config, 0, sizeof(flexcan_timing_config_t));
    if (FLEXCAN_FDCalculateImprovedTimingValues(flexcanConfig.baudRate, flexcanConfig.baudRateFD, EXAMPLE_CAN_CLK_FREQ,
                                                    &timing_config))
{
/* Update the improved timing configuration*/
memcpy(&(flexcanConfig.timingConfig), &timing_config, sizeof(flexcan_timing_config_t));
}
else
{
PRINTF("No found Improved Timing Configuration. Just used default configuration\r\n\r\n");
}
    FLEXCAN_FDInit(EXAMPLE_CAN, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ, BYTES_IN_MB, true);
    FLEXCAN_TransferCreateHandle(EXAMPLE_CAN, &flexcanHandle, flexcan_callback, NULL);
    FLEXCAN_SetRxMbGlobalMask(EXAMPLE_CAN, FLEXCAN_RX_MB_STD_MASK(0x123, 0, 0));
    mbConfig.format = kFLEXCAN_FrameFormatStandard;
    mbConfig.type   = kFLEXCAN_FrameTypeData;
    mbConfig.id     = FLEXCAN_ID_STD(0x123);
    FLEXCAN_SetFDRxMbConfig(EXAMPLE_CAN, RX_MESSAGE_BUFFER_NUM, &mbConfig, true);
    FLEXCAN_SetFDTxMbConfig(EXAMPLE_CAN, TX_MESSAGE_BUFFER_NUM, true);
#endif
 
    while(1)
    {
//    if((param.isEnableCANFD == true))
//    {
CANFDframe.id     = FLEXCAN_ID_STD(0x321);
CANFDframe.format = kFLEXCAN_FrameFormatStandard;
CANFDframe.type   = kFLEXCAN_FrameTypeData;
CANFDframe.length = 10;
CANFDframe.brs = 1;
CANFDtxXfer.mbIdx = TX_MESSAGE_BUFFER_NUM;
CANFDtxXfer.framefd = &CANFDframe;
// FLEXCAN_TransferFDSendBlocking(EXAMPLE_CAN,TX_MESSAGE_BUFFER_NUM,&CANFDframe);
FLEXCAN_TransferFDSendNonBlocking(EXAMPLE_CAN, &flexcanHandle, &CANFDtxXfer);
CANFDSendCount++;
while (!txComplete)
{
};
txComplete = false;
CANFDrxXfer.mbIdx = RX_MESSAGE_BUFFER_NUM;
CANFDrxXfer.framefd = &CANFDframe;
while (!rxComplete)
{
FLEXCAN_TransferFDReceiveNonBlocking(EXAMPLE_CAN, &flexcanHandle, &CANFDrxXfer);
};
rxComplete = false;
PRINTF("Rx MB ID: 0x%3x, Rx MB data: 0x%x, Time stamp: %d\r\n", CANFDframe.id >> CAN_ID_STD_SHIFT,CANFDframe.dataByte0, CANFDframe.timestamp);
//    }
    }
}
0 Kudos
Reply

1,292 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @leonordo 

Can you please let me know your SDK version and which example are you referring?

 

Best regards,

Christine.

Tags (1)
0 Kudos
Reply

1,254 Views
leonordo
Contributor I

hi,I have resolved this issue because my KW38 library function was modified by a previous engineer.

May I ask you a question about the CAN of KW38 or S32K144? I know it has CAN DMA reception function, but does it have CAN DMA transmission function?

0 Kudos
Reply

1,177 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @leonordo 

Thanks for your feedback.

We always suggest to track one issue with one ticket.

Based on the original issue has been resolved.

For the new queries, can you please close this ticket and create a new one to us?

Sorry for the inconvenience to you and thank you for your corporation.

 

Best regards,

Christine.

Tags (1)
0 Kudos
Reply

1,168 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @leonordo 

Thanks for your feedback.

We always suggest to track one issue with one ticket.

Based on the original issue has been resolved.

For the new queries, can you please close this ticket and create a new one to us?

Sorry for the inconvenience to you and thank you for your corporation.

 

Best regards,

Christine.

Tags (1)
0 Kudos
Reply