Flexcan interrupt mode

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

Flexcan interrupt mode

4,807 Views
jay_zhang
Contributor II

Hi NXP devs,

I am using S32K144 to make a OBD product, I need to use the interrupt mode of flexcan, but I cannot find the sample code to use the SDK api.

Below code is what I did in my project to initialize the flexcan:

pastedImage_1.png

After the initialization, when I send a frame, the callback function is called,

pastedImage_2.png

And the code is always print the log, I think I need to clear the send interrupt flag int he callback function, but Id don't know how to do it.

Where I can find the way to do the interrupt mode with flexcan.

Please advice.

Tags (3)
0 Kudos
Reply
4 Replies

3,612 Views
alexandrunan
NXP Employee
NXP Employee

The FLEXCAN_DRV_Init install the handlers for the FLEXCAN MBs if you will replace the handlers with your ones the driver will not work anymore. you can use the FLEXCAN_DRV_InstallEventCallback API to signal the handler interruption for diffrent events like send and receive.

0 Kudos
Reply

3,612 Views
sandeepsandeepk
Contributor II

Sir how to use event callback function acn you send me the sample to use the CAN with interrupt.

0 Kudos
Reply

3,612 Views
jay_zhang
Contributor II

Hi Alexandru,

Thanks for your reply, I tried with FLEXCAN_DRV_InstallEventCallback, it works when I send a can frame, but I cannot get event callback when receiving a can frame before I call FLEXCAN_DRV_Receive function.

So in my mindset, I want to get a receive event when I receive a frame then I can use the receive API to read the frame data.

Can you explain this?

0 Kudos
Reply

3,612 Views
alexandrunan
NXP Employee
NXP Employee

Hello,

You need to call the FLEXCAN_DRV_Receive before seeing the event of callback receive when you see the event of rx complete the message should already be moved in your buffer, because the function will arm the interrupts flags and the callback event signaling will clear the interrupt flag. And if you wish to receive again another message you need to call again the FLEXCAN_DRV_Receive that will rearm the interrupt for a new complete event.

callback function()

{ if(event == RX_COMPLETE)

      FLEXCAN_DRV_Receive;

}

The steps are:

1 Init CAN;

2 Config Callback;

3 call FLEXCAN_DRV_Receive

0 Kudos
Reply