S32K146 CAN FD send state is always BUSY

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K146 CAN FD send state is always BUSY

426 次查看
cjgyf
Contributor II

When running CANFD demo, the BUSY state is always returned when sending data.

Hardware: S32K146 + TJA1145FD

PE configuration:

jiaguangcheng_0-1687160789298.png

 

codes:The software code is based on TJA1145 demo and S32K146 can_pal_s32k146 demo

void Hwi_test()

{

unsigned char ret = 1;
//HWI_TJA1145_Init();
ret = StartupOperation();
//AddTaskToScheduler(CHANGE_TO_NORMAL);
unsigned int count = 0;
TJA1145FD_Transceiver_Status_Reg_t trcvStatus;
TJA1145FD_CAN_Control_Reg_t cc;

(void) TJA1145FD_getTransceiverStatus(&trcvStatus.TJA1145FD_CTS, &trcvStatus.TJA1145FD_CPNERR, &trcvStatus.TJA1145FD_CPNS, &trcvStatus.TJA1145FD_COSCS, &trcvStatus.TJA1145FD_CBSS, &trcvStatus.TJA1145FD_VCS, &trcvStatus.TJA1145FD_CFS);
if (TJA1145FD_getCANControl(&cc.TJA1145FD_CFDC, &cc.TJA1145FD_PNCOK, &cc.TJA1145FD_CPNC, &cc.TJA1145FD_CMC)!= NXP_UJA11XX_SUCCESS) {
ret = E_NOT_OK;
}


CAN_Init(&CAN0_pal1_instance, &CAN0_pal1_Config0);

/* Set information about the data to be sent
* - Standard message ID
* - Bit rate switch enabled to use a different bitrate for the data segment
* - Flexible data rate enabled
* - Use zeros for FD padding
*/
can_buff_config_t buffCfg = {
.enableFD = true,
.enableBRS = true,
.fdPadding = 0U,
.idType = CAN_MSG_ID_STD,
.isRemote = false
};

/* Configure RX buffer with index RX_MAILBOX */
CAN_ConfigRxBuff(&CAN0_pal1_instance, 0, &buffCfg, 0x45);
/* Configure TX buffer with index TX_MAILBOX*/
CAN_ConfigTxBuff(&CAN0_pal1_instance, 1, &buffCfg);

/* Prepare message to be sent */
can_message_t message = {
.cs = 0U,
.id = 0x42,
.data[0] = 0x55,
.length = 8U
};

// extern void TJA1145_main(void);
// TJA1145_main();

/* Send the information via CAN */
CAN_Send(&CAN0_pal1_instance, 1, &message);

while(1)
{
/* Define receive buffer */
can_message_t recvMsg;

/* Start receiving data in RX_MAILBOX. */
// CAN_Receive(&CAN0_pal1_instance, 0, &recvMsg);

/* Wait until the previous FlexCAN receive is completed */
while(CAN_GetTransferStatus(&CAN0_pal1_instance, 1) != STATUS_BUSY)
{
CAN_Send(&CAN0_pal1_instance, 0, &message);
}

// FLEXCAN0_transmit_msg();
// message.data[0] += 1;}

}

Question:

1. Why are you always BUSY? What are the reasons and recommended directions for troubleshooting?

Note: The CAN0 TX port of the S32K146 remains high at all times.

jiaguangcheng_1-1687161390965.pngjiaguangcheng_2-1687161416786.png

 

2.

Is the TX status of CAN0 affected by TJA1145?

Note: The initialization status of TJA1145 is as follows:

jiaguangcheng_3-1687161459061.pngjiaguangcheng_4-1687161486268.png

 

Thanks a lot.

0 项奖励
回复
1 回复

408 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes, you need to have CAN transceiver active so FlexCAN sees CAN bus idle and can be synchronized in it and able to transmit/receive message. FlexCAN ESR1 shows SYNC & IDLE bits cleared. 
Initialize TJA1145 properly so you will be able to communicate with other node connected.

BR, Petr

0 项奖励
回复