Hi NXP,
I need to operate CAN operation with Blocking mode to send data in faster rate. I have tried non blocking mode , there I have not faced any issue. Once I start using Blocking mode , COntroller will reset whenever I configure non zero value.
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/* Found Timeout error and operate at 0 */);
Here it works only with 0, For other Timeout configs it's resetting the board. Could you please help me out? It's failing in semaphore wait might. Which are all the configs I need to consider when I want to use blocking mode operation
Solved! Go to Solution.
Hi@AbhiMR
In the attachment, I have made sample codes for both non-blocking and blocking sending methods.
You can test these two sample projects. If you have any questions or problems, you can point them out and I will help you reproduce and analyze it
This is my test, you can send frame ID = 2 from PC to S32K116, S32K116 will send back the received frame counter and transmited frame counter.
Hi@AbhiMR
Sorry for the long waiting, cause we overloaded recently.
Could you please provided your project and then i will help you to check it.
Further to my debugging info. The semaphore has not been posted to continue the operation. It has to happen from FLEXCAN_CompleteTransfer(instance, mb_idx); . It will happen only when I receive a TX_Complete interrupt even in blocking mode, It's not happening. The config I am using is of for CAN init
flexcan_user_config_t flexcanInitConfig_500k_listen = {
.flexcanMode = FLEXCAN_LISTEN_ONLY_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_user_config_t flexcanInitConfig_500k_listen = {
.flexcanMode = FLEXCAN_LISTEN_ONLY_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_listen);
Hi NXP,
Please find more details. Could you please share 8byte CAN TX operation example with attached setting. Need example in Blocking mode.
Note: CAN TX not working in Blocking mode, it's not hitting any ISR. If not how to get SUCCESS notification?
I have attached all CAN related configuration.
Hi@AbhiMR
In the attachment, I have made sample codes for both non-blocking and blocking sending methods.
You can test these two sample projects. If you have any questions or problems, you can point them out and I will help you reproduce and analyze it
This is my test, you can send frame ID = 2 from PC to S32K116, S32K116 will send back the received frame counter and transmited frame counter.
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 --------------------------------------------------------------------------------------------*/
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.
Thought of trying blocking mode and facing the following issues
/*-----------------------------------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 -------------------------------------------------------------------*/
/*-----------------------------------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 -------------------------------------------------------------------*/
if ((timeoutTicks != OSIF_WAIT_FOREVER) && (delta > max)) /* Line number 349 in osif_baremetal.c */
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