Imx6 Flexcan wec7: better understanding

I would like to get a better understanding of wec7 flexcan api.

  • As I have read there is receive buffer of 256 entries. What about transmit ? Is there also a transmit buffer ? Or will the software try to store the data directly in message buffer of imx6 ?
    When my transmit command returns FALSE, does this mean that the message will not be sent, i.e. I can try later and I can be sure that my message will not be sent twice ?

  • For testing I check the status every 10ms. I quite often get status PASSIVE (about once in 30 seconds). I do not see a reason for this with oszillosope. I never get status BUSOFF and everything seems to work correctly. What is the exact condition for status PASSIVE ?

@Frax222,

Could you please share, Where did you get 256 entries buffer information? There is no software buffer for RX and TX. If we mentioned anywhere then we need to correct our documentation.

Please refer IMX6 TRM section: 27.8.7 Error Counter Register (FLEXCANx_ECR) for more information about CAN Passive error

In

https://www.toradex.com/community/questions/12271/how-to-utilize-interupts-for-can-on-apalis-imx6.html

you find an answer from valter.txt saying:

As I said we have an internal queue that is 255 packets long, this should keep packets for a few ms, even at your current speed

Is this not a receive buffer ? Or is Valter.txt wrong ?

@Frax222,

Sorry, I was wrong about receive buffer, confused with different CAN implementation. Valter shared information is correct.
There are 255 packets software FIFO for receiving in the driver/library. There are no software FIFO for transmitting in the driver/library.

There are two APIs you can use for CAN message transmit:

  1. Imx6Can_Write can send one message and wait for completion/error and transfer next message from Application.

  2. Imx6Can_WriteMultiple can send many messages. Users allocate memory and format messages as many as and then pass to an Imx6Can_WriteMultiple function. It will pass to the CAN driver, the driver will send messages one by one till completion then returns with status.

Apart from that CAN controller has mailboxes. We will share information about that tomorrow.

Hello,

I can not find Imx6Can_WriteMultiple in can_imx6.h .

Is this a new function ?

@Frax222,

Please declare it in the header file can_imx6.h as shown in below. It is already implemented in 2.0 toradex ce libraries. We will correct in the next release.

//******************************************************************************
/// Write multiple CAN Messages
/// * This function requires i.MX6 OS image V1.1Beta3 and later.
/// @param[in]    hPort            HANDLE received from Imx6Can_Init()
/// @param[in]    msg              Pointer to an array of tCanMsg structures
/// @param[in]    numMsgs          number of CAN messages to transmit.
/// @retval       TRUE             Success
/// @retval       FALSE            Failure
BOOL Imx6Can_WriteMultiple(HANDLE hPort, pCanMsg msg, DWORD numMsgs);

status PASSIVE: so I assume that the status directly reflects the bits 4-5 FLT_CONF of FLEXCANx_ESR1. Is this true ?

Sorry,I do not understand “We are not using CAN driver on the release”.
In my application frequency is 500kHz,busload up to 50% or 60%.
At the moment I check the receive queue every 10ms and it seems to work.
If there is no longer a receive queue it will definitely not work - then it will be better to have wrong bus status displayed…

@Frax222,

We were returning wrong bits(3 and 4) to the caller. Now, we have corrected bit 4 and 5 are returning to the caller function. Please download our preliminary version and test it.

We are not using CAN driver on the release. Check Toradex_CE_Libraries.chm file for more information. Since the driver is removed, there will not be 255 Software RX FIFO in the library. Application buffer will be used in the library.

Please confirm, CAN termination resistor is placed properly?

Let us know if you want this fix in 2.0 release and if you face any problem on that.

@Frax222,

Apologize me for wrong information. I confirmed with the developer, driver concept is same ported to the library to get maximum performance. There are 255 SW RX FIFO using CreateMsgQueue is implemented in the library as well.

Let us know if you need any other help.