Suspicious Freescale recommended CAN-polling technique

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Suspicious Freescale recommended CAN-polling technique

1,200 次查看
petpap
Contributor I

Freescales recommendations for polling of CAN-frames are as follows:

 

For each RX-MB where flag is raised:
    reset_flag();

    busy = 1;
    while (busy)
    {
        dummy = mbuff->CS.B.CODE; // locks MB
        busy = (uint8)(0x1 & dummy);
    }
    canId = mbuff->ID;  // extract canID from hardware 
    length = mbuff->CS.B.LENGTH;
    memcpy(data, (uint8*)mbuff->DATA.B, length);
    dummy = touCan->TIMER.R;   // releases lock of MB

 

This introduces a problematic while-loop. We do not want to let this loop potentionally run forever resulting in a watchdog-reset. At the same time limiting the loop so it runs maybe maxumum 10 times may result in lost CAN-frames. If we allow it to run longer, maybe 1000 times this could result in timing issues in our OS.

 

How should we proceed with this while-loop? Does anyone have any ideas it would be gratly appreciated!

 

Best regards,

Peter Pap

标签 (1)
标记 (1)
0 项奖励
回复
1 回复

578 次查看
petpap
Contributor I

I forgot to add that we are using MPC5554 with a FlexCAN2-module!

0 项奖励
回复