FlexCAN Module not able to send the data on CAN Bus

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

FlexCAN Module not able to send the data on CAN Bus

1,715 Views
Kallappa
Contributor III

Hello NXP, I am trying to use the FlexCAN Module with s32k148 Board and send the data via the CAN Bus but data is not able to send on the bus. I attached the code, let me know if something is missing in the configuration.

0 Kudos
8 Replies

1,701 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Kallappa,

There are two FlexCAN examples in S32 SDK that you can refer: can_pal_s32k148 and flexcan_encrypted_s32k148

For example: Please read the documentation of can_pal_s32k148  first.

can_pal_s32k148.png

The example documentation can be found in the S32 SDK documentation at Examples and Demos section. (<SDK_PATH>/doc/Start_Here.html)

CAN PAL S32K148EVB.png


Then configure the PCAN-Pro according to the FlexCAN configuration:
CAN                      FD
Arbitration Phase  500Kbps
Data Phase          1000Kbps

After press SW3 and SW4, the PCAN-Pro will show the CAN message sent from S32K148EVB board 1.

can_pal_s32k148 CAN0 configuration.png

 

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,686 Views
Kallappa
Contributor III
Spoiler
 

Hello Robin,
Thanks for the Quick Support.
As  you suggested I went through the example of the FlexCAN encrypted and I am able to run the code successfully,
But for my use case, I slightly modified the main.c file, because I want to send on start one can message to other board.PFA attached main.c file.
But I am not able to get the data on CAN-BUS even I tried to send the data.

Can you please guide me in this what I missed here?

 

Thanks,

0 Kudos

1,677 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

flexcan_encrypted_s32k148.png

0 Kudos

1,645 Views
Kallappa
Contributor III

Hello Robin,

Thanks a lot for your great support.
now I am able to send the data on can BUS, it is creating interest now in learning the CAN in guidance of you.
Robin, now I want to receive the data as well for that I wrote the code as below attached the DOC.
but not able to receive the data, I was checking the receive buffer but the data is not updated in that buffer.

Kindly help me with this.

Once again thanks,
Kallappa

0 Kudos

1,627 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

When I send CAN data from PCAN, the S32K148EVB is able to toggle LED.(Did you send the data with ID: 74Eh ?)

send and receive.png

 

0 Kudos

1,614 Views
Kallappa
Contributor III

Hello Robin,

my setup is like NXP board is connected with r-pi with CAN Bus and for sending the data i am using the r-pi terminal with the following command.

cansend can0 74E#11111111

NXP Board Side :
My Config is as mentioned below for the Rx and Tx
#if defined(MASTER)
#define TX_MAILBOX (1UL)
#define TX_MSG_ID 0x74F
#define RX_MAILBOX (2UL)
#define RX_MSG_ID 0x74E

===============================================================
flexcan_data_info_t dataInfo =
{
.data_length = 8,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = true,
.fd_enable = true,
.fd_padding = 0U
};

 

/* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX */
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, RX_MAILBOX, &dataInfo, RX_MSG_ID);


======================================================================

flexcan_msgbuff_t recvBuff;


/* Start receiving data in RX_MAILBOX. */
FLEXCAN_DRV_Receive(INST_CANCOM1, RX_MAILBOX, &recvBuff);

/* Wait until the previous FlexCAN receive is completed */
while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX) == STATUS_BUSY);

0 Kudos

1,580 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Sorry for the delay! 
Would you please check if r-pi terminal is corrected configured? I modified the flexcan_encrypted_s32k144 as you shown me in main.
The LEDs is able to toggle.(Check the received message ID toggle LED after FLEXCAN_DRV_Receive )

0 Kudos

1,712 Views
Kallappa
Contributor III



0 Kudos