LPC546 MCANRxFifo assert

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC546 MCANRxFifo assert

ソリューションへジャンプ
808件の閲覧回数
Hector_Jimenez
Contributor III

I'm using MCAN module in LPC54616 MCU in a very unstable environment, which causes assertion in MCAN_ReadRxFifo function when receiving null frames (rxFrame = NULL).

fsl_mcan.c

[...]

status_t MCAN_ReadRxFifo(CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *rxFrame)
{
/* Assertion. */
assert((0U == fifoBlock) || (1U == fifoBlock));
assert(NULL != rxFrame);

[...]

leading into MCU continiously stalling. 

Is this a real assertion reason or could it be sorted out by skipping that reading?

Perhaps it's already been solved in later versions of SDK, can anyone confirm this? My SDK version is 2.10.

Thank you!

 

0 件の賞賛
返信
1 解決策
735件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @Hector_Jimenez 

Yes, you can add related code.

Or  you can add a new function.

status_t CheckFrame(CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *rxFrame)
{
    /* Assertion. */
    assert((0U == fifoBlock) || (1U == fifoBlock));
    if (NULL == rxFrame) {
    	/* Acknowledge the read. */
        if (0U == fifoBlock)
        {
            base->RXF0A = (base->RXF0S & CAN_RXF0S_F0GI_MASK) >> CAN_RXF0S_F0GI_SHIFT;
        }
        else
        {
            base->RXF1A = (base->RXF1S & CAN_RXF1S_F1GI_MASK) >> CAN_RXF1S_F1GI_SHIFT;
        }
        return kStatus_Fail;
    }
    else {
     
         MCAN_ReadRxFifo(base, fifoBlock, rxFrame);
    
}
[...]

BR

Harry

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
770件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @Hector_Jimenez 

In the MCAN_ReadRxFifo function, 

assert(NULL != rxFrame)  is a necessary condition.

 

Snipaste_2025-02-24_16-03-00.png

So it could not be sorted out by skipping that reading.

BR

Harry

0 件の賞賛
返信
765件の閲覧回数
Hector_Jimenez
Contributor III

Hello @Harry_Zhang.

What if we ack the read and return failure? This return value could be checked when calling to MCAN_ReadRxFifo function and set a different status for CAN bus, like kStatus_MCAN_RxFifo0Lost.

status_t MCAN_ReadRxFifo(CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *rxFrame)
{
    /* Assertion. */
    assert((0U == fifoBlock) || (1U == fifoBlock));
    if (NULL == rxFrame) {
    	/* Acknowledge the read. */
        if (0U == fifoBlock)
        {
            base->RXF0A = (base->RXF0S & CAN_RXF0S_F0GI_MASK) >> CAN_RXF0S_F0GI_SHIFT;
        }
        else
        {
            base->RXF1A = (base->RXF1S & CAN_RXF1S_F1GI_MASK) >> CAN_RXF1S_F1GI_SHIFT;
        }
        return kStatus_Fail;
    }
[...]

 

Kind regards

0 件の賞賛
返信
736件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @Hector_Jimenez 

Yes, you can add related code.

Or  you can add a new function.

status_t CheckFrame(CAN_Type *base, uint8_t fifoBlock, mcan_rx_buffer_frame_t *rxFrame)
{
    /* Assertion. */
    assert((0U == fifoBlock) || (1U == fifoBlock));
    if (NULL == rxFrame) {
    	/* Acknowledge the read. */
        if (0U == fifoBlock)
        {
            base->RXF0A = (base->RXF0S & CAN_RXF0S_F0GI_MASK) >> CAN_RXF0S_F0GI_SHIFT;
        }
        else
        {
            base->RXF1A = (base->RXF1S & CAN_RXF1S_F1GI_MASK) >> CAN_RXF1S_F1GI_SHIFT;
        }
        return kStatus_Fail;
    }
    else {
     
         MCAN_ReadRxFifo(base, fifoBlock, rxFrame);
    
}
[...]

BR

Harry

0 件の賞賛
返信
707件の閲覧回数
Hector_Jimenez
Contributor III

Hi, @Harry_Zhang .

We are testing the code I posted and it seems to work fine in these unstable conditions. Some frames are lost, but MCU doesn't get stalled.

Thanks for your help.

Regards!

0 件の賞賛
返信