Using FlexCAN with KSDK and MQX RTOS

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

Using FlexCAN with KSDK and MQX RTOS

1,979 Views
Vagni
Contributor IV

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?

0 Kudos
Reply
5 Replies

1,249 Views
Vagni
Contributor IV

Now I understand the KSDK FlexCAN driver is made to work on a single CAN peripheral (instance) with only one receive Message Buffer at time and only one transmission Message Buffer at Time, because only one flexcan_state_t state structure is available for each instance.

So, in order to have more RTOS tasks working on the same CAN peripheral each with a different couple of Rx/Tx Message Buffers I cannot use the KSDK FlexCAN driver and I need to make by myself a FlexCAN driver working like the PEx CAN_LDD component does.

Any better idea?

0 Kudos
Reply

1,249 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi  Alessandro Vagniluca:

I think you can configure more than one mailboxes , have you tried to configure different mailbox for one can device?

FLEXCAN_DRV_SetRxIndividualMask(instance, kFlexCanMsgIdStd, rxMailboxNum, 0x7FF);

FLEXCAN_DRV_ConfigRxMb(instance, rxMailboxNum, &rxInfo,rxIdentifier);

Regards

Daniel

0 Kudos
Reply

1,249 Views
Vagni
Contributor IV

Hello Daniel,

Yes, I can choose any couple of Rx/Tx Message Buffers for one CAN device, but the KSDK FlexCAN driver can work with only one couple at time, not more as I would like and as I used with the PEx CAN_LDD component.

Regards,

Alessandro

0 Kudos
Reply

1,249 Views
okaner
Contributor III

Hi Alessandro,

    I have same problem. I agree you saying that "I  can choose any couple of Rx/Tx Message Buffers for one CAN device, but the KSDK 1.3 FlexCAN driver can work with only one couple at time, not more as I would like and as I used with the PEx CAN_LDD component." 

How did you solve this problem. This should be a bug right?

0 Kudos
Reply

1,249 Views
Vagni
Contributor IV

Hi Okan,

I didn’t solve the problem.

Fortunately, I could adapt my application using the only one couple of Rx/Tx Message Buffers available in the KSDK 1.3 FlexCAN driver.

I agree with you: the FlexCAN driver should make available all the couples of Rx/Tx Message Buffers.

Best Regards,

Alessandro

Da: okaner

Inviato: venerdì 16 settembre 2016 21:04

A: Alessandro Vagniluca <alessandro.vagniluca@vaber-hs.it>

Oggetto: Re: - Re: Using FlexCAN with KSDK and MQX RTOS

<https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg> NXP Community

Re: Using FlexCAN with KSDK and MQX RTOS

reply from Okan ERCAN <https://community.nxp.com/people/okaner?et=watches.email.thread> in Kinetis Software Development Kit - View the full discussion <https://community.nxp.com/message/832538?commentID=832538&et=watches.email.thread#comment-832538>

0 Kudos
Reply