This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28388D: How to request a transmission using the MCAN TX-FIFO

Part Number: TMS320F28388D

I have the MCAN peripheral working in classic-CAN mode using single CAN-packet transmission/reception and using buffer-mode, and now I am trying to expand that functionality using multiple FIFOs.

When using the TX-buffers, the buffer-data is written using MCAN_writeMsgRam and the transmission is initiated by writing to TXBAR (with the buffer-index). When using FIFOs, is the transmission-request the same or something different? I could not find any example code using multiple FIFOs.

Also, with the TX-buffers and TX-FIFOs sharing the same memory space, is there any advantage to using one over the other? I thought that the FIFO functionality looked more like the C2000 mailbox structure, and the  MCAN_getTxFIFOQueStatus function provided a view of available / empty transmit-space that is not available (or more difficult to get) using the tx-buffers, but this is unclear also.

Thanks,

Jim

  • Hi,

    In order to configure the TX FIFO first you would have to configure the TX FIFO size parameters in the msg ram config params.

    msgRAMConfigParams.txBufNum = 10; // Number of Dedicated Transmit Buffers.
    msgRAMConfigParams.txFIFOSize = 10U; //  Tx FIFO/Queue.

    Same API MCAN_writeMsgRam can be used to add msg data to TX FIFO but with different mem type param.

    MCAN_writeMsgRam(MCAN0_BASE, MCAN_MEM_TYPE_FIFO, 0U, &txMsg);

    Note that when using FIFO the 3rd parameter is a dont care as the put index is read from the fifo status and appropriately the msg is placed in the fifo.

    Initiating transmission request for fifo is same using TXBAR . MCAN_txBufAddReq(MCAN0_BASE, 1U);

    Thanks,

    Yashwant

     

  • Yashwant,

    Thank you for the quick reply; I have another question that hopefully will resolve all of this. If I want to transmit a multi-packet message, do the arguments to MCAN_writeMsgRam and MCAN_txBufAddReq change (besides the CAN-packet data of course)? In other words, can the code look like this:

    txMsg.data = ... //Fill first packet
    MCAN_writeMsgRam(MCAN0_BASE, MCAN_MEM_TYPE_FIFO, 0U, &txMsg);
    MCAN_txBufAddReq(MCAN0_BASE, 1U); //Using FIFO0

    txMsg.data = ... //Fill second packet
    MCAN_writeMsgRam(MCAN0_BASE, MCAN_MEM_TYPE_FIFO, 0U, &txMsg);
    MCAN_txBufAddReq(MCAN0_BASE, 1U); //Still using FIFO0

    This code is not working for me yet, as I appear to be overflowing the MCAN peripheral (many packets, not just 2). Do I need to add some "check previous packet completed" line of code before re-filling the FIFO? I also tried checking the FillLvl before refilling, but that did not work.

    Thanks,

    Jim

  • Jim,

    The parameter for txBufAddReq will change based on the position in the fifo the msg is being added. For multiple packets you can update your code to something like this which reads the fifo put index before adding a msg and using that to add request.

       MCAN_TxFIFOStatus fifoStatus; 
       for(i=0; i<10; i++)
        {
            MCAN_getTxFIFOQueStatus(MCAN0_BASE, &fifoStatus);
            MCAN_writeMsgRam(MCAN0_BASE, MCAN_MEM_TYPE_FIFO,0U, &txMsg);
    
            //
            // Enable Transmission interrupt.
            //
            MCAN_txBufTransIntrEnable(MCAN0_BASE, fifoStatus.putIdx,1U);
    
            //
            // Add request for transmission.
            //
            MCAN_txBufAddReq(MCAN0_BASE, fifoStatus.putIdx);
        }

    Thanks,

    Yashwant