Traveo II: Get the Index of the Last Transmitted CANFD TX Buffer - KBA231463
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
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):
An alternative software method to get the Tx buffer index is shown in the following example:
- 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);
- 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.
- 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;
}
}