S32K3X4EVB-0257 Can4 can recv but can not transmit Can msg

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

S32K3X4EVB-0257 Can4 can recv but can not transmit Can msg

Jump to solution
2,082 Views
baowei_shen
Contributor II

Hi NXP teams:

I configure two Can interfaces on the S32K344 EVB(RTD4.0, EBTresos to config), Can0 sends and receives normally, but Can4 can only receive but not send. My configuration is as follows:

FlexCan0:
FD enabled, 2 HRH (one receiving Standard ID, one receiving Extend ID, respectively using 64Byte RamBlock0/1), 1 HTH (64Byte RamBlock2), 3 HOH HW count are 1, enable RamBlock, not enable TTController, RxFiFo.

FlexCan4:
FD enabled, 2 HRH (one receiving Standard ID, one receiving Extended ID, using Unified 64Byte RamBlock), 1 HTH (Unified 64Byte RamBlock), the HW count of 3 HOHs is 1, RamBlock is enabled on, not enable TTController, RxFiFo.

Polling is used for sending, Interrupt is used for receiving, the normal rate is 500K, FD: 2M, and the sampling rate is 80%. for both Can instance.

HOH configure:

0. ->Receive Std ID Frame for Can0, HW Count: 1

1.  ->Receive Ext ID Frame for Can0, HW Count: 1

2. ->Receive Std ID Frame for Can4, HW Count: 1

3. ->Receive Ext ID Frame for Can4, HW Count: 1

4. ->Transmit Mixed ID Frame for Can0, HW Count: 1

5. ->Transmit Mixed ID Frame for Can4, HW Count: 1

 

Currently Can4 can only receive data, but cannot send it. Using the FlexCan_Ip_SendBlocking function will report an error: FLEXCAN_STATUS_BUFF_OUT_OF_RANGE

I found this error is generated from FlexCan_Ip_SendBlocking->FlexCAN_StartSendData->FlexCAN_IsMbOutOfRange.
The parameter passed to FlexCAN_IsMbOutOfRange is MBIndex: 5, MaxMbNum: 0, so it reported an error when the FlexCAN_IsMbOutOfRange Exit.


My initialization code is as follows. What is the possible cause of this problem and how can I fix it? Thank you!

baowei_shen_0-1731909781540.pngbaowei_shen_1-1731909794087.png

#S32K3X4EVB-0257 #Flex

Tags (2)
0 Kudos
Reply
1 Solution
1,937 Views
DanNguyenDuy
NXP Employee
NXP Employee

Hello @baowei_shen,

You passed into wrong the first parameter in this statement:

FlexCAN_Ip_SendBlocking(1, 2, &TestMsgForm, 2U, dummyData, 100);

The first parameter (Flexcan_Ip_u8Instance) must be 4 (FlexCan4) instead of 1 (FlexCan1)

Best regards,

Dan

View solution in original post

0 Kudos
Reply
10 Replies
1,998 Views
DanNguyenDuy
NXP Employee
NXP Employee

Hello @baowei_shen,

I checked the generated files with your configuration.

With CanController_1 (FLEXCAN_4), the .max_num_mb = 3 and u8MbIndex = 2 with HTH

DanNguyenDuy_0-1732092286288.png

DanNguyenDuy_1-1732092407272.png

I tested with statement: Can_43_FLEXCAN_Write(Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_5, &Can_PduInfo). The  FlexCAN_IsMbOutOfRange() was returned false because the  if (u8MbIndex >= (uint8)u32MaxMbNum) didn't happen (u8MbIndex = 2 and u32MaxMbNum = .max_num_mb = 3).

Please re-check parameters that passed into the Can_43_FLEXCAN_Write() function in your project.
 
Best regards,
Dan
0 Kudos
Reply
1,993 Views
baowei_shen
Contributor II

Hi @DanNguyenDuy :

I'm currently use Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_5 as parameter for FlexCAN_Ip_SendBlock, so it is because i use the wrong parameter?

 

As your method, i should use u8MbIndex:14 for FlexCan0 and u8MbIndex:2 for FlexCan4 pass to FlexCAN_Ip_SendBlock, am i right?

 

0 Kudos
Reply
1,986 Views
DanNguyenDuy
NXP Employee
NXP Employee

Hello @baowei_shen,

Yes, correct.

Best regards,

Dan

0 Kudos
Reply
1,956 Views
baowei_shen
Contributor II

Hi @DanNguyenDuy 

I edited my code as below:

void CanIf_Init(void)
{
uint32 u32Idx = 0U;
Std_ReturnType RetVal = E_OK;

static uint8 dummyData[8] = {0,1,2,3,4,5,6,7};
static Flexcan_Ip_DataInfoType TestMsgForm = {
.data_length = 8u,
.msg_id_type = FLEXCAN_MSG_ID_EXT,
.is_polling = true,
#if (FLEXCAN_IP_FEATURE_HAS_FD == STD_ON)
.fd_enable = CAN_IF_FD_EN,
.fd_padding = 0xcc,
#endif
.is_remote = false,
};

CanIf_QueueInit(&CanMsgQueue); /* My own queue, using for restore Can message */

/* Initilize Can driver */
Can_43_FLEXCAN_Init(&Can_43_FLEXCAN_Config_VS_0);

/* Init FlexCan0 Transceiver */
CanIf_TJA1153_Init(0, \
Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_4, \
85U, \
84U);
RetVal = Can_43_FLEXCAN_SetControllerMode(Can_43_FLEXCANConf_CanController_CanController_0, CAN_CS_STARTED);
if(RetVal != E_OK)
{
DEBUG_PRINT("Can_43_FLEXCAN_SetControllerMode for FlexCan0 failed, Reason: %u \r\n", RetVal);
}

/* Init FlexCan4 Transceiver */
CanIf_TJA1153_Init(0, \
Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_5, \
111U, \
109U);
RetVal = Can_43_FLEXCAN_SetControllerMode(Can_43_FLEXCANConf_CanController_CanController_1, CAN_CS_STARTED);
if(RetVal != E_OK)
{
DEBUG_PRINT("Can_43_FLEXCAN_SetControllerMode for FlexCan4 failed, Reason: %u \r\n", RetVal);
}

/* Use Can_43_FLEXCAN_Write to send via FlexCan0 */
RetVal = CanIf_Send(0, Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_4, &TestMsgForm, 1U, dummyData);
if(E_OK != RetVal)
{
DEBUG_PRINT("CanIf_Send for FlexCan0 failed, Reason: %u \r\n", RetVal);
}

/* Use Can_43_FLEXCAN_Write to send via FlexCan4 */
RetVal = CanIf_Send(0, Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_5, &TestMsgForm, 2U, dummyData);
if(E_OK != RetVal)
{
DEBUG_PRINT("CanIf_Send for FlexCan0 failed, Reason: %u \r\n", RetVal);
}

/* Use FlexCAN_Ip_SendBlocking to send via FlexCan0 */
RetVal = FlexCAN_Ip_SendBlocking(0, 14, &TestMsgForm, 2U, dummyData, 100);
if(E_OK != RetVal)
{
DEBUG_PRINT("FlexCAN_Ip_SendBlocking for FlexCan0 failed, Reason: %u \r\n", RetVal);
}

/* Use FlexCAN_Ip_SendBlocking to send via FlexCan4 */
RetVal = FlexCAN_Ip_SendBlocking(1, 2, &TestMsgForm, 2U, dummyData, 100);
if(E_OK != RetVal)
{
DEBUG_PRINT("FlexCAN_Ip_SendBlocking for FlexCan0 failed, Reason: %u \r\n", RetVal);
}
}

Std_ReturnType CanIf_Send(uint8 CanController, Can_HwHandleType CanTxHandler, const Flexcan_Ip_DataInfoType *pMsgInfo, uint32 u32MsgId, uint8 *pu8Data)
{
Std_ReturnType RetVal = E_OK;
Can_PduType CanMsg;
uint8 u8Timeout = 10U;

CanMsg.id = u32MsgId;
CanMsg.length = pMsgInfo->data_length;
CanMsg.sdu = pu8Data;
CanMsg.swPduHandle = 123;

u8TxConfirmed = (uint8)FALSE;
RetVal = Can_43_FLEXCAN_Write(CanTxHandler, &CanMsg);
if(E_OK == RetVal)
{
while((u8TxConfirmed == (uint8)FALSE) && (u8Timeout != 0))
{
Can_43_FLEXCAN_MainFunction_Write();
CanIf_DummyDelay(100);
u8Timeout--;
}

if((u8TxConfirmed == (uint8)TRUE) && (u8Timeout == 0U))
{
/* Failed to transmit Can msg */
RetVal = E_NOT_OK;
DEBUG_PRINT("[%s:%d] Timeout to transmit Can msg\r\n",__FUNCTION__,__LINE__);
}
else
{
DEBUG_PRINT("[%s:%d] Transmit done, timeout: %u\r\n",__FUNCTION__,__LINE__,u8Timeout);
}
}
else
{
DEBUG_PRINT("[%s:%d] Can_43_FLEXCAN_Write failed reason: %u\r\n",__FUNCTION__,__LINE__, RetVal);
}

return RetVal;
}

 and the result is:

baowei_shen_0-1732155096543.png

If i use the function Can_43_FLEXCAN_Write to send can msg, both FlexCan0/4 works

But when i use FlexCAN_Ip_SendBlocking  to send msg, only FlexCan0 works, even though i used MbIndex:2 for FlexCan4, And you can check the last 2 line in the result pic, when i passed MbIndex:2 to FlexCAN_Ip_SendBlocking, the u32MaxMbNum is not 3 but 0.

Is this a bug or i'm using FlexCAN_Ip_SendBlocking  in the wrong way?

 

 

Tags (2)
0 Kudos
Reply
1,938 Views
DanNguyenDuy
NXP Employee
NXP Employee

Hello @baowei_shen,

You passed into wrong the first parameter in this statement:

FlexCAN_Ip_SendBlocking(1, 2, &TestMsgForm, 2U, dummyData, 100);

The first parameter (Flexcan_Ip_u8Instance) must be 4 (FlexCan4) instead of 1 (FlexCan1)

Best regards,

Dan

0 Kudos
Reply
1,919 Views
baowei_shen
Contributor II

Hi @DanNguyenDuy 

Very appreciate your work, I thought should use the CanController ID for parameter.

Thank you very much.

By the way, do you know why when i configure the TJA1153, the driver will trasmit timeout, but TJA1153 recv and configure successfully. Is this normal?

Tags (1)
0 Kudos
Reply
1,909 Views
DanNguyenDuy
NXP Employee
NXP Employee

Hello @baowei_shen,

In my opinion, it can be relevant to your TJA1153 configuration.

I attached a TJA1153 example based on the RTD S32K3 2.0.1 version. You can refer to this example to check your project.

Besides, NXP also provided the CANTRCV_TJA115X_4.4_1.0.1 package that supports TJA115x, you can refer to the CanTrcv_tja115x_S32K344_EBT example in this package.

Best regards,

Dan

0 Kudos
Reply
2,027 Views
DanNguyenDuy
NXP Employee
NXP Employee

Hello @baowei_shen,

1. What is the correct name of the RTD package you are using? (for example: SW32K3_S32M27x_RTD_R21-11_4.0.0_P01)

2. What is the purpose of the CanIf_TJA1153_Init() function? Is it related to FlexCAN4 registers?

3. What is the value of "CanControllerID" in the Can_43_FLEXCAN_SetControllerMode() function that caused the failure?

4. Could you send me your configuration files?

Best regards,

Dan

0 Kudos
Reply
2,010 Views
baowei_shen
Contributor II

Hi @DanNguyenDuy :

1. What is the correct name of the RTD package you are using? (for example: SW32K3_S32M27x_RTD_R21-11_4.0.0_P01)

R: We are using SW32K3_S32M27x_RTD_R21-11_4.0.0

 

2. What is the purpose of the CanIf_TJA1153_Init() function? Is it related to FlexCAN4 registers?

R: No impact on FlexCan4 register, TJA1153 is NXP secure can transceiver, it need configure via TX to work, So basically TJA1153_Init just send some Can package using FlexCan_Ip_SendBlocking.

 

3. What is the value of "CanControllerID" in the Can_43_FLEXCAN_SetControllerMode() function that caused the failure?

R: CanControllerID is 1U which represent FlexCan4, The Can_43_FLEXCAN_SetControllerMode function also return E_NOT_OK.

 

4. Could you send me your configuration files?

Off course, The Zip package contains CanIf(V4.0.0, AS4.7.0), Can_43_FLEXCAN(V4.0.0, AS4.7.0)

 

Hope these info could help.

Best Regard.

0 Kudos
Reply
2,045 Views
baowei_shen
Contributor II
Please ignore the FlexCAN_SetMsgBuffNum call in initial function, it's mistake
0 Kudos
Reply