This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377D-EP: A method 'while' escape condition in driverlib can.c

Part Number: TMS320F28377D-EP

hello

I have a question about using the can example code.

* F2837xD_common \ driverlib \ can.c

  - TI Release: F2837xD Support Library v210

  - Release Date: Tue Nov  1 14:46:15 CDT 2016

In can.c, the while conditional statement is written as an infinite loop as shown below.

Here, I wonder if it is impossible to escape if the while conditional escape condition is not satisfied.

For example, I wonder if there are other conditions such as the condition that you can get out of the while door after a certain period of time.

--------------- while  ---------------------------------------------------------------------

  // Wait for busy bit to clear
while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
{
}

// Wait for busy bit to clear
while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
{
}

// Wait for busy bit to clear
while(HWREGH(ui32Base + CAN_O_IF2CMD) & CAN_IF2CMD_BUSY)
{
}

// Wait for busy bit to clear.
while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
{
}

etc.... 

* Please understand that I used a translator.

  • I wonder if it is impossible to escape if the while conditional escape condition is not satisfied.

    Correct, if the busy is stuck at 1, it is impossible to escape this loop.

    I wonder if there are other conditions such as the condition that you can get out of the while door after a certain period of time.

    Not the way the Driverlib is written right now. One approach you could take is to put in a "for" loop and break out of the loop when the s/w counter is 0.

  • Thanks for your reply.
    I have additional questions.

    I'm trying to put an escape condition on 'while'.

    Can you modify the F2837xD_common\driverlib\can.c example code above?

  • I cannot modify the published Driverlib code. Perhaps you could try something like the below: (You need to determine the delay value based on your application needs)

    for(i=0; i<delay_count; i++)

                   {

                                     if((HWREGH(base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY) != CAN_IF1CMD_BUSY){break;}

                    }

                  break;