Solved! Go to Solution.
Hi Roc_Wang,
At least, I checked that related can driver, didn't find the specific API to clear it, just the status information updated code.
You can use your mentioned code, I think this MSCAN driver just design like that.
Or you also can use the baremetal code, which control the register directly.
Wish it helps you!
Best Regards,
Kerry
Hi Roc_Wang,
As you know, the KEA128 MSCAN TX has 3 MB,
So, you can use MSCAN_CANTFLG[TXE] to check which MB.
3bit means 3 related MB.
Wish it helps you!
If you still have questions about it, please kindly let me know.
Best Regards,
Kerry
Hi Kerry,
thank you for your help.
We are using the api function "Transmit_CAN_MB" and "Load_CAN_MB" in MSCAN_KEA_DEVD to transmit messages.
The MB is a data buffer struct defined in MSCAN_KEA_DEVD.
We do not know the correspondence between data buffers and MSCAN transmitter ,so can not use MSCAN_CANTFLG[TXE] directly.
Sorry for the confusing.
Which API can we use ?
Hi Roc_Wang,
Please let me know your IDE: CW or S32DS or KDS?
Then I will help you to check this driver.
Best Regards,
Kerry
S32DS.
Thank you.
Hi Roc_Wang,
I think, it needs to use Check_CAN_MB_Status, this API contains the ABuffer, it should used to check the detail MB situation:
err_status = Check_CAN_MB_Status(0, 0, buffer_status);
while (buffer_status[0] != NEWDATA) //Wait for the Receive ISR to finish and change the buffer status, NEWDATA indicates that the buffer has receive a new data
{
err_status = Check_CAN_MB_Status(0, 0, buffer_status);
}
Wish it helps you!
Best Regards,
Kerry
Hi Kerry,
thank you for your help.
Yes, the MB situation can be checked by using Check_CAN_MB_Status, when the Data Frame has been transmitted successfully, the status of the Message Buffer changes to TRANSMITTED.
But, how to clear this status ? It always be TRANSMITTED until a new message is loaded into th MB.
Hi Roc_Wang,
I think the following code may helps your understanding, I think you can modify the related MB->status:
bufferMode = (MSCANBuffers[AChn_Transformed]+ABuffer)->Mode;
bufferStatus = (MSCANBuffers[AChn_Transformed]+ABuffer)->Status;
if (!((bufferMode == TXDF) || (bufferMode == TXRF)))
{
if (!(CCRcopy))
{
CLI; /* restore interrupt mask */
}
return (ERR_CONFIG);
}
if ((bufferMode == TXDF) && (bufferStatus == NODATA))
{
if (!(CCRcopy))
{
CLI; /* restore interrupt mask */
}
return (ERR_NODATA);
}
if ((bufferStatus == QUEUED) /* MB already queued */
|| (bufferStatus == QUEUED2)
|| (bufferStatus == ABORTREQ))
{
if (!(CCRcopy))
{
CLI; /* restore interrupt mask */
}
return (ERR_QED);
}
Queue_CAN_MB ( AChn, ABuffer); /* queue buffer, copy to msCAN if buffer available, */
/* abort msCAN buffer if all full and this buffer higher priority */
----------
You also can check this API:CAN_Transmit
You can find the related MB clear code:
else /* transmission completed */
{
if ((p_Buffer + buffer)->Mode == TXRF) /* transmitted remote frame */
{
(p_Buffer + buffer)->Mode = RXDF; /* receive data frame */
(p_Buffer + buffer)->Status = NODATA;
}
else /* transmitted Data TXDF or AUTOTXDF */
{
(p_Buffer + buffer)->Status = TRANSMITTED;
}
# if (TIMESTAMP_CAN)
if (TimeStampOption[AChn_Transformed])
{
p->CANTBSEL.Byte = interruptBufferBit;
(p_Buffer + buffer)->BufferTimeStamp_CAN = p->CANTXTSR.Word;
}
# endif
}
You can modify the status to your wanted data.
Wish it helps you!
Best Regards,
Kerry
Hi Kerry,
so do you mean there is not an existing API to clear it?
It works normally if I used the code below:
uint8_t liMbSt[2] ;
/*Tx confirmed*/
if(MSCAN_CANTFLG & MSCAN_CANTIER)
{
CAN_Transmit(0);
McuAbs_Write_MsCanTransmittedInd(STD_ON);
Check_CAN_MB_Status(0,MSG_BUFFER_ID_DIAG,liMbSt);
if(TRANSMITTED == liMbSt[0])
{
(MSCANBuffers[vChnIdx[0]]+MSG_BUFFER_ID_DIAG)->Status = NODATA;
CanAif_MsgTxConfirm();
}
}
Thank you !
Hi Roc_Wang,
At least, I checked that related can driver, didn't find the specific API to clear it, just the status information updated code.
You can use your mentioned code, I think this MSCAN driver just design like that.
Or you also can use the baremetal code, which control the register directly.
Wish it helps you!
Best Regards,
Kerry
Get it !
Thank you !