AnsweredAssumed Answered

Flexcan Mailbox not proper unlocking under freertos (maybe cache problem)

Question asked by Moritz Kunze on Jan 30, 2018
Latest reply on Aug 9, 2018 by zhang jie

So i use the flexcan drivers with mailboxes under the sdk 0.8.6 with freertos on the s32k144 (engineering samples right now).



First receiveBlocking call to can works properly, any subsequent is blocking forever/timeouting with status TIMEOUT despite there are can messages qualifiying are on the bus and received by the can core. It happens on can and canfd packages.


Mitigation in debugger:

A. Read !any! of the registers of the Flexcan peripheral between receives does allow a subsequent receive

B. Doing the RxMailbox Configuration again will allow one more package to be received (tested doing this after a timeout will result in an timeout/success/timeout cycle).


Mitigation in runtime:

use nonblocking and callback works



CAN or CANFD with 500kbits, CPU Clock from PLL with 80MHz, Busclock with 10/20/40MHz tested, PE Clock is CPU/Sys Clock with 80MHz, but 16MHz from SOSC does also not work. 

CAN PE works, as the frames are acknowledged.

Optimization is disabled.



Cache problems might be an issue due to to rather "tricky" way to lock and unlock mailboxes and the read to the timer to unlock "(void)*base->TIMER" is cached?



check if cache disable will help, but need info howto do it





INT_SYS_SetPriority(CAN0_ORed_IRQn, 4);
INT_SYS_SetPriority(CAN0_Error_IRQn, 4);
INT_SYS_SetPriority(CAN0_Wake_Up_IRQn, 4);
INT_SYS_SetPriority(CAN0_ORed_0_15_MB_IRQn, 4);
INT_SYS_SetPriority(CAN0_ORed_16_31_MB_IRQn, 4);


FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);




flexcan_data_info_t info = {
.msg_id_type = FLEXCAN_MSG_ID_STD, /*!< Type of message ID (standard or extended)*/
.data_length = 64, /*!< Length of Data in Bytes*/
.fd_enable = true, /*!< Enable or disable FD*/
.fd_padding = 0, /*!< Set a value for padding. It will be used when the data length code (DLC)
specifies a bigger payload size than data_length to fill the MB */
.enable_brs = true, /*!< Enable bit rate switch inside a CAN FD format frame*/
.is_remote = false, /*!< Specifies if the frame is standard or remote */

FLEXCAN_DRV_ConfigRxMb (INST_CANCOM1, 0 , &info, 0);

flexcan_msgbuff_t msgIn;

while(1) {

      status = FLEXCAN_DRV_ReceiveBlocking(INST_CANCOM1, 0 , &msgIn, 1000);

      if (status == STATUS_SUCCESS) {
    /* process frame */
    } else {
     /* reset mbx */
     FLEXCAN_DRV_ConfigRxMb (INST_CANCOM1, 0 , &info, 0);