KEAZ128 MSCAN

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,887件の閲覧回数
Roc_Wang
Contributor I
Hi NXP, there are some questions when we use the mscan driver "MSCAN_KEA_DEVD". We have configured three MBs to transmit three different messages, after the message has been transimitted successfully ,the TX interrupt will be triggered. How to find which MB triggered the interrupt event in TX IRQ? Check_CAN_MB_Status ?
0 件の賞賛
返信
1 解決策
1,839件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

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

元の投稿で解決策を見る

0 件の賞賛
返信
10 返答(返信)
1,872件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Roc_Wang,

    As you know, the KEA128 MSCAN TX has 3 MB,

kerryzhou_0-1618303148286.png

So, you can use MSCAN_CANTFLG[TXE] to check which MB.

kerryzhou_1-1618303213839.png

3bit means 3 related MB.

 

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

 

0 件の賞賛
返信
1,868件の閲覧回数
Roc_Wang
Contributor I

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 ?

0 件の賞賛
返信
1,864件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信
1,857件の閲覧回数
Roc_Wang
Contributor I

S32DS.

Thank you.

0 件の賞賛
返信
1,856件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信
1,852件の閲覧回数
Roc_Wang
Contributor I

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.

0 件の賞賛
返信
1,850件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信
1,848件の閲覧回数
Roc_Wang
Contributor I

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 !
   

0 件の賞賛
返信
1,840件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信
1,830件の閲覧回数
Roc_Wang
Contributor I

Get it !

Thank you !

0 件の賞賛
返信