FlexCAN How can I get data frame signal on loop-back mode

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

FlexCAN How can I get data frame signal on loop-back mode

跳至解决方案
2,590 次查看
buccno
Contributor III

Hi all,

I am using an eval board with an S32k116 processor. I wrote a simple code about the FlexCAN-BUS protocol, I could see in the IDE that the data I sent was successfully transmitted. But I'm having trouble with the signal,

1st one; How can I see the data frame signal using a logic analyzer? (I connected the logic analyzer to the CAN TX pin, but it was constantly showing high when I read the reference manual, it said it would always show high or low.)

RMS32K1xx CAN TX: This pin is the transmit pin to the CAN bus transceiver. The dominant state is represented by logic level 0. The recessive state is represented by logic level 1.


2nd one; When I put the transmit and receive function I wrote into an infinite loop (I verified that it works by turning on the LED and in the expression section). When I connected the oscilloscope probes to the CAN HIGH and CAN LOW outputs, I could not get a proper signal. What would be the reason? I used to send and receive functions in blocking mode.)

 

标记 (4)
0 项奖励
回复
1 解答
2,479 次查看
buccno
Contributor III

Hey Petr, I was wrong to set my CAN transceiver wake-up pins. My problem was solved—no such things as masking. Thanks for all your reply.

在原帖中查看解决方案

0 项奖励
回复
10 回复数
2,562 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

in loopback mode you will see nothing on CAN pins. Change configuration for normal mode, also modify bit timing, probably 83kbps is not desired one.

PetrS_0-1670326792822.png

Also board have to be powered with external 12V so SBC's transceiver is active. Then you should see transmitted message on CAN pins.

BR, Petr

2,554 次查看
buccno
Contributor III

Thanks a lot for your answer.


My current problem is; I enter timeout in receive or transmit functions in normal mode.

When I call the Confix RX function and call the receive function, I enter the timeout. When I use normal receive instead of blocking, I do not enter timeout. I am sending data from an external source. (Same ID with receive func)

Should I call another function?

0 项奖励
回复
2,545 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you can simply use nonblocking function with testing transfer status

ret = FLEXCAN_DRV_Receive(INST_FLEXCAN_CONFIG_1, RX_MAILBOX, &received_data);

while(FLEXCAN_DRV_GetTransferStatus(INST_FLEXCAN_CONFIG_1, RX_MAILBOX) != STATUS_SUCCESS) {;}

It will wait on while loop until message is received.

BR, Petr

0 项奖励
回复
2,540 次查看
buccno
Contributor III

Is this look good?


#define MSG_ID_1 (0x02)

#define MB_RX_0 (1U)

uint32_t CAN_config(const uint8_t mb_id, const uint32_t msg_id)
{
flexcan_data_info_t dataInfo =
{
.data_length = 8U,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = false,
.fd_enable = false,
.fd_padding = 0U
};

status_t ret = FLEXCAN_DRV_ConfigRxMb(INST_FLEXCAN_CONFIG_1, mb_id, &dataInfo, msg_id);

return (ret == STATUS_SUCCESS);
}


uint32_t CAN_receive_data(const uint8_t mb_id)
{
flexcan_msgbuff_t rcv_data = {0};

/*rcv_data.cs = 0;
rcv_data.data =*/

//FLEXCAN_DRV_SetRxMaskType(INST_FLEXCAN_CONFIG_1, type_mask);

status_t ret = FLEXCAN_DRV_Receive(INST_FLEXCAN_CONFIG_1, mb_id, &rcv_data); //BLOCKING

while(FLEXCAN_DRV_GetTransferStatus(INST_FLEXCAN_CONFIG_1, mb_id) != STATUS_SUCCESS) {;}

return (ret == STATUS_SUCCESS);
}

标记 (4)
0 项奖励
回复
2,538 次查看
buccno
Contributor III

buccno_0-1670418153439.png

I can send data in the CAN analysis program, I think the trace part confirms this. But there is no success from GetTransferStatus in S32DS.

0 项奖励
回复
2,527 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

be sure your RX MB is configured to receive the ID you sent from CAN tool.
Or clear mask register to receive all IDs, for test.

BR, Petr

0 项奖励
回复
2,515 次查看
buccno
Contributor III

Sorry, I know, I ask a lot of questions but how can I clear register all ID's? IDK. My peripheral window is empty. I cannot check. 

0 项奖励
回复
2,509 次查看
PetrS
NXP TechSupport
NXP TechSupport
0 项奖励
回复
2,480 次查看
buccno
Contributor III

Hey Petr, I was wrong to set my CAN transceiver wake-up pins. My problem was solved—no such things as masking. Thanks for all your reply.

0 项奖励
回复
2,568 次查看
buccno
Contributor III

my test code, here

0 项奖励
回复