RT1052, The data transfered by CAN is received by itself

cancel
Showing results for 
Search instead for 
Did you mean: 

RT1052, The data transfered by CAN is received by itself

Jump to solution
757 Views
yu998877
Contributor II

//Initial configuration:

FLEXCAN_Init(CAN2, &flexcanConfig, EXAMPLE_CAN_CLK_FREQ);
FLEXCAN_TransferCreateHandle(CAN2, &flexcanHandle, flexcan_callback, NULL);

//Receive configuration:

flexcan_rx_mb_config_t mbConfig;

mbConfig.format = kFLEXCAN_FrameFormatStandard;
mbConfig.type = kFLEXCAN_FrameTypeData;
mbConfig.id = FLEXCAN_ID_STD(0x123);
FLEXCAN_SetRxMbConfig(CAN2, 9, &mbConfig, true);

FLEXCAN_SetRxMbGlobalMask(CAN2, FLEXCAN_RX_MB_STD_MASK(0x123, 0, 0));

flexcan_frame_t rx_frame;
flexcan_mb_transfer_t rxXfer;

rx_frame.id = FLEXCAN_ID_STD(0x123);
rx_frame.format = kFLEXCAN_FrameFormatStandard;
rx_frame.type = kFLEXCAN_FrameTypeData;
rx_frame.length = 8;

rxXfer.mbIdx = 9;
rxXfer.frame = &rx_frame;
//Initially configured to enable the MB9 interrupt
FLEXCAN_TransferReceiveNonBlocking(CAN2, &flexcanHandle, &rxXfer);

//Transfer configuration:
FLEXCAN_SetTxMbConfig(CAN2, 8, true);

//Data transfer:
flexcan_frame_t rx_frame;
flexcan_mb_transfer_t txXfer;
txXfer.mbIdx = 8;
txXfer.frame = &tx_frame;
//......Fill data into tx_frame......
FLEXCAN_TransferSendNonBlocking(CAN2, &flexcanHandle, &txXfer);

/*

enableLoopBack is disabled!
enableLoopBack is disabled!
enableLoopBack is disabled!

As long as FLEXCAN_TransferSendNonBlocking is called to transfer data, MB9 data will be received in flexcan_callback with status=kStatus_FLEXCAN_RxIdle, The data content is the same as the transfer data

*/

The blue picture is the data received by the can card connected computer:

微信图片_20220619102904.png

The data sent by can2 of rt1052 was received by can2 immediately, and my can card did not reply the data to can2。

 

What's the problem?

 

Labels (1)
0 Kudos
1 Solution
712 Views
Joey_van_Hummel
Contributor III

Check the status of CAN->MCR[SRX_DIS]. I think it is what you want.

jh2_0-1655725346503.png

 

View solution in original post

9 Replies
713 Views
Joey_van_Hummel
Contributor III

Check the status of CAN->MCR[SRX_DIS]. I think it is what you want.

jh2_0-1655725346503.png

 

708 Views
yu998877
Contributor II

I have not configured CAN->MCR[SRX_DIS], this bit is 0.

0 Kudos
700 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @yu998877 

   jh2's recommendation is correct, please set the CAN->MCR[SRX_DIS] =1, then frames transmitted by the module will not be stored in any MB, regardless if the MB is programmed with an ID that matches the transmitted frame, and no interrupt flag or interrupt signal will be generated due to the frame reception. This bit can only be written in Freeze mode as it is blocked by hardware in other modes.

  In default, this bit is 0, that's why you can receive your own transmit ID.

Best Regards,

Kerry

685 Views
yu998877
Contributor II

yes,
this bit is 0, that's I can receive own transmit ID.

I didn't look carefully before. I thought Bit=1 was "self reception enabled". I was wrong. This is the right reason.

The trouble for us is that "pconfig->disableselfreception = false" is configured by default in the "FLEXCAN_GetDefaultConfig" function.

The SDK version I used is 2.11.1. I suggest that the SDK of the next version should be configured to true by default

@kerryzhou   @jh2

Thanks!

717 Views
alessioschisano
Contributor II

Same problem as you, just set up the ID filter

719 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @yu998877 ,

   This is the correct result when your CAN sent the standard id 0X123.

   As you know, the CAN node will receive all the data from the CAN bus, even it's own data, so you can use the ID filter to filter the own ID.

  But you set the RX:

rx_frame.id = FLEXCAN_ID_STD(0x123);

  So, it means you also can receive the 0X123 from the bus, that's why when you send the 0X123, then you also can receive it, if you sendout other ID, it should not be received when you use the filter.

 

Wish it helps you!

Best Regards,

Kerry

 

0 Kudos
707 Views
yu998877
Contributor II

I don't agree with you. In actual use, the sending ID and receiving ID will be the same, so the filter cannot be used to avoid.

I don't have this problem when using other can controllers, including other NXP can controllers.

 

0 Kudos
725 Views
yu998877
Contributor II

I have not configured CAN->CTRL1[LPB]

222.png444.png

0 Kudos
728 Views
jay_heng
NXP Employee
NXP Employee

It seems to be in FlexSPI loopback mode, so the data will be transferred via internal path, not via external pins. please check CAN->CTRL1[LPB] bit.

0 Kudos