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

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

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

Jump to solution
2,480 Views
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.)

 

0 Kudos
Reply
1 Solution
2,369 Views
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.

View solution in original post

0 Kudos
Reply
10 Replies
2,452 Views
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,444 Views
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 Kudos
Reply
2,435 Views
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 Kudos
Reply
2,430 Views
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);
}

0 Kudos
Reply
2,428 Views
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 Kudos
Reply
2,417 Views
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 Kudos
Reply
2,405 Views
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 Kudos
Reply
2,399 Views
PetrS
NXP TechSupport
NXP TechSupport
0 Kudos
Reply
2,370 Views
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 Kudos
Reply
2,458 Views
buccno
Contributor III

my test code, here

0 Kudos
Reply