Freescales recommendations for polling of CAN-frames are as follows:
For each RX-MB where flag is raised:
busy = 1;
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!