CAN Interrupt

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Interrupt

518 Views
onurdemirel
Contributor III

Hello,

I am working with KE18F and trying to use FLEXCAN.

My aim is setting up the CANbus and wait for the incoming messages that initiates the interrupt subroutine. I want to use CAN0_ORed_Message_buffer_IRQn and its function. I somehow enter this subroutine when I try to send a data using another mailbox and stay in that subroutine continiously. 

I set up interrupt as below:

FLEXCAN_Enable_MbInterrupts(CAN0, CAN_IMASK1_BUF31TO0M(RXMB_NUM));

EnableIRQ(CAN0_ORed_Message_buffer_IRQn);

I also create handle

FLEXCAN_TransferCreateHandle(CAN0, &flexcanHandle, flexcan_callback, NULL);

The interrupt enters after

FLEXCAN_TransferSendNonBlocking(CAN0,&flexcanHandle,&txXfer);

Where I am missing, and how can I figure out what the problem is? Where should I check?

Thanks in advance,

Onur

Tags (2)
0 Kudos
3 Replies

108 Views
onurdemirel
Contributor III

Hello,

I realize I miss some information about this. 

Inside the interrupt IRQHandler function I call FLEXCAN_ClearMbStatusFlags(CAN0, CAN_IMASK1_BUF31TO0M(RXMB_NUM)); function to clear the flag and interrupt but it is not working for now. 

I also changed the scenario and start for waiting a CAN message first and I send CAN message via CANBusAnalyzer. After the sent operation, it enters to IRQHandler function and stays inside without doing anything else.

From my point of view I think I am missing some part to disable interrupt and it goes always into the interrupt handler. 

Other problem is how to distinguish sending Mailbox interrupt and receiving Mailbox interrupt. After doing the clearing (somehow) the interrupt flag, I will work on this distinguishing issue. 

Thanks in advance,

Onur

0 Kudos

108 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Onur,

    About the KE18 flexCAN interrupt code, in our SDK sample code for KE18, there has a flexcan_interrupt_transfer project, do you check our official code at first? You can try the official code at first which can be downloaded from this link:

Welcome | MCUXpresso SDK Builder 

select the KE18 chip, generate the code and download it, you can find the interrupt code in folder:

SDK_2.2_TWR-KE18F\boards\twrke18f\driver_examples\flexcan\interrupt_transfer

If you still have problem after try it, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

108 Views
onurdemirel
Contributor III

Hello Kerry,

Yes I did looked for the examples and tried to get help from them. I understood callback mechanism after I asked this question. Callback function is called upon interrupt and sets flag. Instead of looking for incoming message and setting an interrupt, using flags that are set in callback function is easier and more error-free. 

With this callback function I can check whether the transmission is receiving or transmitting by looking its flag.

Thanks for answer and the help,

Onur

0 Kudos