Other Parts Discussed in Thread: TCAN4550
Tool/software: Code Composer Studio
Hello there.
I'm Alex.Kim. I want to ask you question of transmission missing.
In our system, we send periodically a message through TxBuf of TCAN4550.
However, sometimes we're not able to receive messages from TCAN4550.
(If there are so many other messages what have high priority in same network, The abnormal behavior are happened very much.)
Please check my transmit routine and result.
And another thing I'd like to ask is that is there any method to check the completion of TCAN4550 transmission?
(I can't get any result from TC of MCAN Interrupts. Even though not only I set up TCE as 1 but also DAR is 0.)
thank you.
best regards.
Std_ReturnType TCAN4550_Transmit(uint32_t id, uint8_t* data, uint8_t module)
{
Std_ReturnType retValue = E_NOT_OK;
uint8_t i = 0;
uint8_t msgObjectId = 0;
uint8_t msgObjectLength = 0;
TCAN4550_IdTypeType TCAN4550_IdType;
TCAN4550_DataTypeType TCAN4550_DataType;
TCAN4x5x_MCAN_TX_Header header = {0};
Can_IdType msgId;
/* Seek tcan4550 object */
for(i = 0; !TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_EOL; i++)
{
if((TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_ObjectHwModule == module) &&
(TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_MsgId.msgId == id))
{
msgObjectId = TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_ObjectId;
msgObjectLength = TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_ObjectMsgLength;
TCAN4550_IdType = TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_IdType;
TCAN4550_DataType = TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_DataType;
msgId = TCAN4550_RuntimeGlobal.config->TCAN4550_Hoh[i].TCAN4550_MsgId.msgId;
retValue = E_OK;
break;
}
}
if (retValue == E_OK)
{
if (msgObjectLength <= 8) {
header.DLC = msgObjectLength; // Set the DLC to be equal to or less than the data payload (it is ok to pass a 64 byte data array into the WriteTXFIFO function if your DLC is 8 bytes, only the first 8 bytes will be read)
}
else if (msgObjectLength == 12) {
header.DLC = MCAN_DLC_12B;
}
else if (msgObjectLength == 16) {
header.DLC = MCAN_DLC_16B;
}
else if (msgObjectLength == 20) {
header.DLC = MCAN_DLC_20B;
}
else if (msgObjectLength == 24) {
header.DLC = MCAN_DLC_24B;
}
else if (msgObjectLength == 32) {
header.DLC = MCAN_DLC_32B;
}
else if (msgObjectLength == 48) {
header.DLC = MCAN_DLC_48B;
}
else if (msgObjectLength == 64) {
header.DLC = MCAN_DLC_64B;
}
else {header.DLC = 0;}
header.ID = msgId;
if (TCAN4550_DataType == TCAN4550_DATA_TYPE_FD)
{
header.FDF = 1;
header.BRS = 1;
}
else
{
header.FDF = 0;
header.BRS = 0;
}
if (TCAN4550_IdType == TCAN4550_ID_TYPE_EXTENDED)
{
header.XTD = 1;
}
else
{
header.XTD = 0;
}
header.EFC = 0; // Don't use Event FIFO Control
header.MM = 0; // Don't use Message Marker
header.RTR = 0; // Don't use Remote Transmission Request
header.ESI = 0; // Don't use Error state indicator
for (i = 0; i < msgObjectLength; i++)
{
TCAN4550_TxData[i] = (uint8_t)data[i];
}
TCAN4x5x_MCAN_WriteTXBuffer(msgObjectId, &header, TCAN4550_TxData);
TCAN4x5x_MCAN_TransmitBufferContents(msgObjectId);
}
return E_OK;
}