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.)
解決済! 解決策の投稿を見る。
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.
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.
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
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?
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
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);
}
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.
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
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.
Hi,
you can refer to below thread for masking demo
https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-FlexCAN-Mask-Setting-Demo/ta-p/1519753
BR, Petr
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.