Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Traveo II: Get the Index of the Last Transmitted CANFD TX Buffer - KBA231463

Traveo II: Get the Index of the Last Transmitted CANFD TX Buffer - KBA231463

ChaitanyaV_61
Employee
Employee
50 questions asked 25 likes received 25 sign-ins

Author: HongyanW_86            Version: **

In Traveo™ II MCU, after the CAN FD message in the Tx buffer is transmitted, the corresponding bit of the CANFDx_CHx_TXBTO register is set, but it will be reset only when a new transmission is requested.  Therefore, the last transmitted Tx buffer index may not be identified directedly by the value in the CANFDx_CHx_TXBTO register.

See the following description of the CANFDx_CHx_TXBTO register in TVII-B-E-1M Register TRM (002-19567 Rev. *F):

image1.png

An alternative software method to get the Tx buffer index is shown in the following example:

  1. Enable Tx buffer transmission interrupt by setting the corresponding bit in the CANFDx_CHx_TXBTIE register when the Tx transmission is requested.

//Enable one Tx buffer interrupt 

pstcCanFD->M_TTCAN.unTXBTIE.u32Register = 1ul << vTxBufferIndex;

//Transmit Tx message in the Tx buffer

Cy_CANFD_UpdateAndTransmitMsgBuffer(CY_CANFD_TYPE, vTxBufferIndex, &stcMsg);

  1. When the Transmission Completed interrupt is set (CANFDx_CHx_IR.TC = 1), the last transmitted Tx buffer index can be identified by checking the CANFDx_CHx_TXBTIE and CANFDx_CHx_TXBTO registers. When this bit of both registers are set, the corresponding bit is the index of the last transmitted Tx Buffer.

  2. Clear CANFDx_CHx_TXBTIE register.

//Get TXBTIE register value

vTxBufIntStatus = pstcCanFD->M_TTCAN.unTXBTIE.u32Register;

//Check bits of register TXBTIE and TXBTO

for(vIndex=0;vIndex < 32;vIndex++)

{

        vTxbufStatus = Cy_CANFD_GetTxBufferStatus(pstcCanFD,vIndex);

        //TXBTIE.bit == 1 and TXBTO.TOx =1, TX buffer transmit occured/successful and TXBCF.CFx =0 no cancel

        if (((1ul << vIndex)& vTxBufIntStatus) && (vTxbufStatus == CY_CANFD_TX_BUFFER_TRANSMIT_OCCURRED))

        { 

            //disable Tx buffer interrupt 

            pstcCanFD->M_TTCAN.unTXBTIE.u32Register = 0x00000000;  

            //vIndex is the last transmitted Tx buffer index

            gTxBufferIndex = vIndex;

        }

    }

0 Likes
504 Views