S32K396 Transmit and receive multiple CAN messages (polling)

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

S32K396 Transmit and receive multiple CAN messages (polling)

956 Views
ashwinibalkwade
Contributor II

I am trying to send and process or perform another CANTx/Tx on received CAN message.

 

Also, how can I do same with Interrupts?

0 Kudos
Reply
7 Replies

764 Views
ashwinibalkwade
Contributor II

Hi @PetrS ,

 

I have successfully transmitted multiple messages on CAN bus. 

I am still stuck  in situation for receiving CAN messages. Please see the attached screenshots, Even if I am not sending any message still "RStatus" is "FLEXCAN_STATUS_SUCCESS", and when I am sending message from PCAN then also the "RStatus" is "FLEXCAN_STATUS_SUCCESS".

The msgID shows some garbage value.

Tags (1)
0 Kudos
Reply

762 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

if want to use polling mode then have below code for each reception. This would be 
- start receiving, i.e. call FlexCAN_Ip_Receive
- check status using FlexCAN_Ip_GetTransferStatus and call FlexCAN_Ip_MainFunctionRead repeatedly to process received message in given MB.

FlexCAN_Ip_Receive(INST_FLEXCAN_0, RX_MB_IDX, &rxData, TRUE);
while(FlexCAN_Ip_GetTransferStatus(INST_FLEXCAN_0, RX_MB_IDX) !=FLEXCAN_STATUS_SUCCESS)
{ FlexCAN_Ip_MainFunctionRead(INST_FLEXCAN_0, RX_MB_IDX); }
...process received data in user buffer here

BR, Petr

0 Kudos
Reply

758 Views
ashwinibalkwade
Contributor II

Hi @PetrS ,

 

I tried this but FlexCAN_Ip_GetTransferStatus(INST_VS_0_FLEXCAN_0, RX_MB_IDX) returns "FLEXCAN_STATUS_SUCCESS" every time.

When I debugged the code I found that the below base->IFLAG1 is setting to 0 and hence causing the skipping of while loop.

ashwinibalkwade_0-1726749506404.png

 

Can you please help me to know from where is this getting set to 0, I tried debugging but didn't find the exact loophole?

 

0 Kudos
Reply

675 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

share simplified project you are using now, to check how driver's function are used.

BR, Petr

0 Kudos
Reply

922 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you can refer to below example which shows multiple MBs usage with interrupt/callbacks too.
https://community.nxp.com/t5/S32K-Knowledge-Base/Example-S32K344-FlexCAN-Ip-TX-RX-EnhanceRXFIFO-test...
It is for S32K344, but it is similar.

BR, Petr

0 Kudos
Reply

830 Views
ashwinibalkwade
Contributor II

Hi @PetrS ,

 

Can we transmit or receive multiple messages at same time, do not want to send or receive messages for that blocking period only? 

0 Kudos
Reply

819 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

did not get a point much.
On the bus there is always just single message at the time, the one sent from a node which won bus arbitration. If node/MCU is receiving this message, it will be stored in MB/RXFIFO if MB/RXFIFO was configured to receive this message. Meanwhile a node can have prepared other MBs for message transmissions and those will be transmitted once selected by internal arbitration process and after first opportunity window on the bus.

BR, Petr

0 Kudos
Reply