Hi NXP,
I am sharing all my CAN config. Better if you can provide working example with 8byte TX payload.
Please refer the details that we elaborated more
In our application we have the following configuration, which are of initialization and run time operation to transmit the can frame.
/*-------------------------------------------------INIT PART ---------------------------------------------------------------------------------------------------*/
flexcan_user_config_t flexcanInitConfig_500k = {
.flexcanMode = FLEXCAN_NORMAL_MODE,
.fd_enable = false,
.payload = FLEXCAN_PAYLOAD_SIZE_8,
.max_num_mb = 16UL,
.num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
.is_rx_fifo_needed = false,
.transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,
.rxFifoDMAChannel = 0U,
.pe_clock = FLEXCAN_CLK_SOURCE_OSC,
.bitrate = {
.propSeg = 7UL,
.phaseSeg1 = 4UL,
.phaseSeg2 = 1UL,
.preDivider = 1UL,
.rJumpwidth = 1UL
}
};
FLEXCAN_DRV_Init(INST_FLEXCAN_CONFIG_1, &flexcanState0, &flexcanInitConfig_500k);
/* Install callback function */
FLEXCAN_DRV_InstallEventCallback(INST_FLEXCAN_CONFIG_1, flexcanCallBack, NULL);
FLEXCAN_DRV_InstallErrorCallback(INST_FLEXCAN_CONFIG_1, flexcanErrorCallBack, NULL);
/*--------------------------------------------------INIT Completed --------------------------------------------------------------------------------------------*/
Non-Blocking Mode
We have developed our application to transmit CAN frame at every 100ms. In non-blocking mode able to use FLEXCAN_DRV_Send method to transfer CAN Buffer , where we can get FLEXCAN_EVENT_TX_COMPLETE response in the above configured callback "flexcanCallBack". It behaves as expected.
/*------------------------------ Runtime operation ----------------------------------------------*/
FLEXCAN_DRV_Send(INST_FLEXCAN_CONFIG_1, E_MB_MSG_TX, &arrayMessageBufferInfo[E_MB_MSG_TX].rx_info, psCanFrameToSend->u32Identifier, psCanFrameToSend->au8Data);
/*------------------------------ Runtime operation ----------------------------------------------*/
In the above implementation we have drawback in transmission of frame at higher speed in non-blocking mode. Transmission is getting delayed whenever we have CAN request on the same time.
Blocking mode
Thought of trying blocking mode and facing the following issues
- With Timeout 0UL able to send the CAN frame with expected speed in our application without notifying success message. It will always return STATUS_TIMEOUT from blocking call. We suspect not safer in implementation.
/*-----------------------------------Runtime Operation -------------------------------------------------------------------*/
Returnvalue=FLEXCAN_DRV_SendBlocking(INST_FLEXCAN_CONFIG_1, E_MB_MSG_TX, &arrayMessageBufferInfo[E_MB_MSG_TX].rx_info, psCanFrameToSend->u32Identifier, psCanFrameToSend->au8Data, (uint32_t)0UL);
/*-----------------------------------Runtime Operation -------------------------------------------------------------------*/
- I tried sending data with timeout(Any Value from 1UL ) to get STATUS_SUCCESS . In this case controller will go for hang state.
/*-----------------------------------Runtime Operation -------------------------------------------------------------------*/
Returnvalue=FLEXCAN_DRV_SendBlocking(INST_FLEXCAN_CONFIG_1, E_MB_MSG_TX, &arrayMessageBufferInfo[E_MB_MSG_TX].rx_info, psCanFrameToSend->u32Identifier, psCanFrameToSend->au8Data, (uint32_t)10UL);
/*-----------------------------------Runtime Operation -------------------------------------------------------------------*/
- Observation is that controller is stuck at OSIF_SemaWait function, because stopped producing osif_Tick. The following line of controller got hang, observed delta is 0 to hang the controller.
if ((timeoutTicks != OSIF_WAIT_FOREVER) && (delta > max)) /* Line number 349 in osif_baremetal.c */
- Not received any TX completion interrupt to post semaphore from ISR. Since Post semaphore we have at FLEXCAN_CompleteTransfer function.
NOTE: It's not hitting any ISR in CAN Blocking mode
Since we don’t have to process anything in non-blocking mode for TX operation. We want to try blocking mode with STATUS_SUCCESS message.
Could you please review the above details and provide us the detail to fix the same and let us know the list of methods to improve CAN TX frame transmission from the application. Share suitable examples to explore all the methods.
Additional note:
Controller: S32k116
SDK Version : S32SDK_S32K1XX_RTM_4.0.2
Referred link : file:///C:/NXP/S32DS.3.4/S32DS/software/S32SDK_S32K1XX_RTM_4.0.2/doc/html_S32K116/group__flexcan__driver.html