AnsweredAssumed Answered

Using FlexCAN with KSDK and MQX RTOS

Question asked by Alessandro Vagniluca on Oct 26, 2015
Latest reply on Sep 21, 2016 by Alessandro Vagniluca

On a TWR-K65F180M I tried the FlexCAN demoes flexcan_loopback and flexcan_network that come with KSD 1.3.0.

I ported those demoes on my new CAN application on the same board using KDS 3.0.0 + PEx + MQX_KSDK Standard.

Like demoes, my application defines and use one RX Message Buffer and One TX Message Buffer among the 16 FlexCAN available buffers.

 

Now I need to have in my application two distinct CAN tasks operating on the same CAN bus, each task using a different couple of Rx/TX Message Buffers with assigned different RX and TX identifiers, e.g. one task uses RX_MB=0 with MB_ID=0x123 and TX_MB=8 with MB_ID=0x145, the other task uses RX_MB=1 with MB_ID=0x167 and TX_MB=9 with MB_ID=0x189.

 

For frame trasmissions I just have to call  FLEXCAN_DRV_Send() with the right TX_MB and MB_ID. But what if a would check the transmission end on a single TX Message Buffer? The FLEXCAN_DRV_GetTransmitStatus() returns the transmit status of the CAN peripheral, not for a single TX Message Buffer, right? How can I achieve the transmit status of a single TX Message Buffer?

 

For frame reception I just have to start reception on a RX Message Buffer calling FLEXCAN_DRV_RxMessageBuffer(). But the FLEXCAN_DRV_GetReceiveStatus() driver function returns the receive status of the CAN peripheral, right?. How can I check the reception on a single RX Message Buffer? Should I use the CAN Message Buffer interrupt handler to read what type of interrupt (TX or RX) was generated on which Message Buffer? If yes, how?

 

Finally, I need to wake up my task on its CAN reception. How can I achieve this with the available CAN driver functions? Should I use instead some of the HAL functions for the FlexCAN peripheral in some way?

 

In the past I developed on a K60 cpu another CAN application with MQX and the CAN_LDD components provided by Processor Expert. The CAN_LDD component provides call-back functions for success event on a TX Message Buffer and for a receive event on a RX Message Buffer, the buffer ID being a parameter of the call-back function. Is there a way to get the same with KSDK FlexCAN driver functions?

Outcomes