S32K3 CAN-FD RX interrupt not occuring

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

S32K3 CAN-FD RX interrupt not occuring

Jump to solution
1,828 Views
Kazarian
Contributor III

Hello, 

We try to implement CAN-FD in interrupt mode based on the example “FlexCAN_Ip_Example_S32K344” which is not that useful since it use loopback and no interrupts.

What we tried to do is :

Create interrupt in IntCtrl_IP : FlexCAN0_1_IRQn , handler : CAN0_ORED_0_31_MB_IRQHandler

Kazarian_0-1732099187138.png

In FlexCan modul add callback function : flexcan0_Callback

Kazarian_1-1732099200155.png

 

Install the interrupts (please refere to attached file function FlexCan_Init_Config)

Implement the Callback function :  flexcan0_Callback

Modul can send the frames, but the reception is not triggering, can you please verify attached code and let me know what is you thought.

We want to receive Ids from 0x100 to 0x7FF. only STD ids not extended ones 

 

 

const Flexcan_Ip_EnhancedIdTableType CAN0_EnhanceFIFO_IdFilterTable[1] =
{
		{
			.filterType = FLEXCAN_IP_ENHANCED_RX_FIFO_RANGE_ID_FILTER,
			.isExtendedFrame = false,
			.id1 = 0x7FF ,	// STD ID From
			.id2 = 0x100, 	// STD ID To
			.rtr2 = FALSE,	// RTR filter
			.rtr1 = FALSE,	// RTR mask
		},
};

 

 

 Best regards.

Tags (1)
0 Kudos
Reply
1 Solution
1,617 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Kazarian

Please Copy Flexcan.c to your project and try agian, this should be an error caused by accessing temporary variables.

Senlent_0-1732514338430.png

 

View solution in original post

9 Replies
1,795 Views
Kazarian
Contributor III

The hardfault comes if i set the payload in my Can frame to 64 byte , if i set it to whatever other smaller value (32-24-16..) the program run and i can receive frames correctly. 

Kazarian_0-1732181623540.png

 

Flexcan_Ip_DataInfoType rx_info = {
	        .msg_id_type = FLEXCAN_MSG_ID_STD,
	        .data_length = 64u,
	        .is_polling  = FALSE,
	        .is_remote   = FALSE,
			.fd_enable   = TRUE,
	};

 

Where should i change so can be able to receive a payload of 64bytes without hardfault ?

 

Regards.

 

0 Kudos
Reply
1,618 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Kazarian

Please Copy Flexcan.c to your project and try agian, this should be an error caused by accessing temporary variables.

Senlent_0-1732514338430.png

 

1,604 Views
Kazarian
Contributor III

@Senlent Thanks a lot this works.

I'm looking to set a range of Standard CAN IDs, for example, from 0x100 to 0x300, without using the enhanced RX FIFO, which only supports 20 CAN FD messages.

Is there a method to achieve this? Alternatively, if that’s not possible, a global mask that would allow the device to accept all IDs would also work for my application.

0 Kudos
Reply
1,600 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Kazarian

Please refer to this article which is also same with S32K3 mask settings.

https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-FlexCAN-Mask-Setting-Demo/ta-p/1519753

 

0 Kudos
Reply
1,790 Views
Kazarian
Contributor III

Register view

Kazarian_0-1732202037182.pngKazarian_1-1732202074231.png

 

0 Kudos
Reply
1,767 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Kazarian

This may be related to the number of MB settings you have.

Please provide a complete demo if you encounter problems.

0 Kudos
Reply
1,709 Views
Kazarian
Contributor III

Hello @Senlent 

i emailed you the code in private message.

Number of MB is 2, below is the configuration.

 

Kazarian_0-1732261935128.png

 

Kazarian_1-1732261954422.png

Thank you.

0 Kudos
Reply
1,809 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Kazarian

Please see attached, this is a demo I made a while ago.

0 Kudos
Reply
1,800 Views
Kazarian
Contributor III

Hello @Senlent 

Thanks a lot for your answer, 

The MCU goes to hardfault when i send a can frame from my CAN-Case into the MCU.

i can however send frames from MCU to my Canoe. 

i want to set a range of ids not only 1, and im using CAN-FD with 64 bytes, here is init function, can you please update the RX filter and also why the MCU hard fault ?

between im using Freertos i dont know how usefull this info can be !

 

Flexcan_Ip_StatusType FlexCan_Init_Config(void)
{
	Flexcan_Ip_StatusType retVal = E_NOT_OK;

	Flexcan_Ip_MsgBuffType rxData;

	Flexcan_Ip_DataInfoType rx_info = {
	        .msg_id_type = FLEXCAN_MSG_ID_STD,
	        .data_length = 64u,
	        .is_polling  = FALSE,
	        .is_remote   = FALSE,
			.fd_enable   = TRUE,
	};

	/* Enable interrupt on CAN 0 */
	IntCtrl_Ip_EnableIrq(FlexCAN0_0_IRQn);
	IntCtrl_Ip_EnableIrq(FlexCAN0_1_IRQn);
	IntCtrl_Ip_EnableIrq(FlexCAN0_2_IRQn);

	retVal = FlexCAN_Ip_Init(INST_BOARD_INITPERIPHERALS_FLEXCAN_0, &FlexCAN_BOARD_InitPeripherals_State0, &FlexCAN_Config0_BOARD_InitPeripherals);

	retVal |= FlexCAN_Ip_SetRxIndividualMask(INST_BOARD_INITPERIPHERALS_FLEXCAN_0,RX_MB_IDX,0xFFFFFFFF);

	retVal |= FlexCAN_Ip_ConfigRxMb(INST_BOARD_INITPERIPHERALS_FLEXCAN_0, RX_MB_IDX, &rx_info, Rx_MSG_ID);

    /* Set the FlexCAN instance in START mode */
	retVal |= retVal |= FlexCAN_Ip_SetStartMode(INST_BOARD_INITPERIPHERALS_FLEXCAN_0);


	retVal |= FlexCAN_Ip_Receive(INST_BOARD_INITPERIPHERALS_FLEXCAN_0,RX_MB_IDX,&rxData,FALSE);


    return retVal;
}

 

Thank you.

 

Tags (1)
0 Kudos
Reply