Hi their,
I am using CAN0 in S32K144 and using Rx FiFo mechanism in that via Interrupts.
My configurations are:
1) Format A Filter table and 8 Rx Filter elements
2) CAN0 at 500kbps, Rx Fifo enabled and via interrupts
And in the main() i have written this code:
// RX FIFO Filter table structure
const Flexcan_Ip_IdTableType GB_FlexCAN_IdFilterTable[8] = {
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x320
},
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x330
},
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x340
},
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x350
},
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x360
},
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x370
},
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x380
},
{
.isRemoteFrame = FALSE,
.isExtendedFrame = FALSE,
.id = 0x390
}
};
int main(void)
{
Flexcan_Ip_StatusType FlexCAN_Api_Status;
/* Write your code here */
Clock_Ip_Init(&Mcu_aClockConfigPB[0]);
#if defined (FEATURE_CLOCK_IP_HAS_SPLL_CLK)
while ( CLOCK_IP_PLL_LOCKED != Clock_Ip_GetPllStatus() )
{
/* Busy wait until the System PLL is locked */
}
Clock_Ip_DistributePll();
#endif
IntCtrl_Ip_EnableIrq(CAN0_ORed_0_15_MB_IRQn);
IntCtrl_Ip_InstallHandler(CAN0_ORed_0_15_MB_IRQn, CAN0_ORED_0_15_MB_IRQHandler, NULL_PTR);
/* Initialize all pins using the Port driver */
Port_Init(NULL_PTR);
/* Initilisize FlexCAN Module according to FlexCAN_Config0 data structure */
FlexCAN_Ip_Init(INST_FLEXCAN_0, &FlexCAN_State0, &FlexCAN_Config0);
/* Configure the RxFIFO with corresponding ID filter table acceptance format and acceptance message ID's*/
FlexCAN_Api_Status = FlexCAN_Ip_ConfigRxFifo_Privileged(INST_FLEXCAN_0, FLEXCAN_RX_FIFO_ID_FORMAT_A, &GB_FlexCAN_IdFilterTable);
/* Start the FlexCAN Module */
FlexCAN_Api_Status = FlexCAN_Ip_SetStartMode(INST_FLEXCAN_0);
/* RxFiFo in non-blocking method*/
FlexCAN_Api_Status = FlexCAN_Ip_RxFifo(INST_FLEXCAN_0, &GB_FlexCAN_Receive_Data);
for(;;)
{
/* RxFiFo in non-blocking method*/
FlexCAN_Api_Status = FlexCAN_Ip_RxFifo(INST_FLEXCAN_0, &GB_FlexCAN_Receive_Data);
TestDelay(20000000);
}
return 0;
}
/* END main */
/*!
** @}
*/
Now my question and issue is that under the infinite for loop, i have written FlexCAN_Api_Status = FlexCAN_Ip_RxFifo(INST_FLEXCAN_0, &GB_FlexCAN_Receive_Data);. It works fine and my Interrupt is working fine.
But if i remove this API from for loop and put it above for loop and in for loop its just delay like this:
/* RxFiFo in non-blocking method*/
FlexCAN_Api_Status = FlexCAN_Ip_RxFifo(INST_FLEXCAN_0, &GB_FlexCAN_Receive_Data);
for(;;)
{
TestDelay(20000000);
}
Then my interrupt is not generated regularly. It only generates for first time and once it enters in for loop then if i send CAN data my Rx FiFo interrupt is not generated for the message ID that are configured in filter table.
So why is this happening? As if I am using interrupt it should trigger interrupt in infinite loop if any CAN received data comes in. Do we have to call FlexCAN_Ip_RxFifo() API everytime to receive data? If that is the case, isnt that wrong because if i have to call API to receive data everytime then its fundamental usecase would not happen.
Let me know if i am missing something and what should be workaround. My ask is simple that i want to receice CAN data via Rx FiFo in interrupt data if any new can data of configured message id comes, even if code is in infinite loop
Hi@Kunal_Gettobyte
Please refer to this post and also you can find demo in this articles.
https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-FlexCAN-Mask-Setting-Demo/ta-p/1519753
Hi,
Thanks, problem solved.
Thanks