How to use FlexCAN_Ip in S32K344

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

How to use FlexCAN_Ip in S32K344

Jump to solution
3,764 Views
MateoSegura413
Contributor III

Hello,

I am currently trying to implement a simple example described below

- S32K344 FlexCAN module will interrupt whenever it get's a message, at which point a new RTOS thread will read the values from the message received.

I started the project using the "FlexCAN_Ip_Example_S32K344", however it is not clear at all how to use this IP to get anything useful done. 

- How do I link my own code the interrupt handler?

- How do I read CAN without wasting CPU cycles?

Any help or guidance would be greatly appreciated.

Mateo Segura 

0 Kudos
Reply
1 Solution
3,672 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

testing your code I got FLEXCAN_EVENT_TX_COMPLETE event in the callback, red LED is flashing with 1sec rate. Enabling receive on MB1 by uncommenting below line

PetrS_0-1645186823162.png

a FLEXCAN_EVENT_RX_COMPLETE event is hit too and green LED is also toggled.

BR, Petr

View solution in original post

0 Kudos
Reply
4 Replies
3,737 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the FlexCAN_Ip_Example_S32K344 do simple transmit/receive testing in loopback mode. NOt sure if thee is anything with freeRTOS too.
Generally, if you do not want to have SW polling, you can install callback function which will be called from MB's interrupt. Within flexcan component add 

PetrS_0-1644329659210.png

 

if send/receive function will be called with parameter indicating non-polled mode then callback function will be called upon successful transmission or reception. 
you can check attached modified code for this example.

Hope it helps

BR, Petr

0 Kudos
Reply
3,695 Views
MateoSegura413
Contributor III

Hey @PetrS, first of, thank you very much for your response.

I tried to incorporate your example into a design studio project, but unfortunately the callback is not being called. I have tried it in loopback mode as well as out to a CAN tranceiver connected to a test board and no results either way. I have attached the project, is there anyway you could please take a quick look at it and tell me what I'm doing wrong?

Thanks...

0 Kudos
Reply
3,673 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

testing your code I got FLEXCAN_EVENT_TX_COMPLETE event in the callback, red LED is flashing with 1sec rate. Enabling receive on MB1 by uncommenting below line

PetrS_0-1645186823162.png

a FLEXCAN_EVENT_RX_COMPLETE event is hit too and green LED is also toggled.

BR, Petr

0 Kudos
Reply
3,637 Views
MateoSegura413
Contributor III

This worked. Thank you!

0 Kudos
Reply