CAN full duplex with RX FiFos and TX with same driver configurations not possible ?

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

CAN full duplex with RX FiFos and TX with same driver configurations not possible ?

1,586 Views
pradeep_tewani1
Contributor I

I want to use CAN RX with interrupts/callbacks and CAN TX simultaneously ( ie a Full duplex) .

 

I have managed to configure CAN RX with FiFos ( for using DMA and a CALLBACK ). Using config0 on CAN0 in processor expert.

 

  EDMA_DRV_Init(&dmaController1_State, &dmaController1_InitConfig0, edmaChnStateArray, edmaChnConfigArray, EDMA_CONFIGURED_CHANNELS_COUNT);
  FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
  FLEXCAN_DRV_RxFifo(INST_CANCOM1, &recvBuff2);
  FLEXCAN_DRV_ConfigRxFifo(INST_CANCOM1, FLEXCAN_RX_FIFO_ID_FORMAT_A, filterTable);
  FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1,&rx_fifo_callback,NULL);
  

 

With this I can receive CAN messages well.

If I wish to simultaneously send a message I cannot do that by writing.

 

          FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1, MB, &dataInfo, MSG_ID);
          /* Execute send non-blocking */
          FLEXCAN_DRV_Send(INST_CANCOM1, MB, &dataInfo, MSG_ID, &FrameLen);
          /* Wait until the previous FlexCANsend is completed */
          while (FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, MB) == STATUS_BUSY);

 

 

I found a workaround to this by de initializing CAN RX FIFO configuration (canCom1_InitConfig0) and enabling another configuration (&canCom1_InitConfig1) with RX FiFos disabled.

 

  FLEXCAN_DRV_Deinit(INST_CANCOM1);
  FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig1);

 

 

However as I am de initializing (canCom1_InitConfig0) case whenever I am sending a CAN message , I am unable to receive any new message which might be of a higher priority.

What I want is to send a CAN message , while also wait / stay available/open to receive a new CAN message.

Attached the configs and main.c file.

const flexcan_user_config_t canCom1_InitConfig0 = {
    .fd_enable = false,
    .pe_clock = FLEXCAN_CLK_SOURCE_OSC,
    .max_num_mb = 16,
    .num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
    .is_rx_fifo_needed = true,
    .flexcanMode = FLEXCAN_NORMAL_MODE,
    .payload = FLEXCAN_PAYLOAD_SIZE_8,
    .bitrate = {
        .propSeg = 7,
        .phaseSeg1 = 4,
        .phaseSeg2 = 1,
        .preDivider = 4,
        .rJumpwidth = 1
    },
    .bitrate_cbt = {
        .propSeg = 7,
        .phaseSeg1 = 4,
        .phaseSeg2 = 1,
        .preDivider = 4,
        .rJumpwidth = 1
    },
    .transfer_type = FLEXCAN_RXFIFO_USING_DMA,
    .rxFifoDMAChannel = 0U
};
const flexcan_user_config_t canCom1_InitConfig1 = {
    .fd_enable = false,
    .pe_clock = FLEXCAN_CLK_SOURCE_OSC,
    .max_num_mb = 16,
    .num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
    .is_rx_fifo_needed = false,
    .flexcanMode = FLEXCAN_NORMAL_MODE,
    .payload = FLEXCAN_PAYLOAD_SIZE_8,
    .bitrate = {
        .propSeg = 7,
        .phaseSeg1 = 4,
        .phaseSeg2 = 1,
        .preDivider = 4,
        .rJumpwidth = 1
    },
    .bitrate_cbt = {
        .propSeg = 7,
        .phaseSeg1 = 4,
        .phaseSeg2 = 1,
        .preDivider = 4,
        .rJumpwidth = 1
    },
    .transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,
    .rxFifoDMAChannel = 0U
};

I don't think the `.transfer_type` in canCom1_InitConfig1 is of any relevance as RX FiFos are disabled.

I could not find any references to this in the SDK reference manual.

Any help would be highly appreciated.

 

 

0 Kudos
Reply
1 Reply

1,577 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

there should be no issue with that.
Within callback function in FLEXCAN_EVENT_TX_COMPLETE event use some variable indicating TX complete operation. Based on this you can call FLEXCAN_DRV_Send again within main while loop.

There is example showing RXFIFO and regular MBs (TX/RX) usage at https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5748G-FlexCAN-RXFIFO-SDK-PA-RTM200-S3.... it is for older SDK, but principle is the same

BR, Petr

0 Kudos
Reply