AnsweredAssumed Answered

Problem in OSA_TimeDelay() - fsl_os_abstraction_bm.c (KSDK 1.3.0)

Question asked by Derek Casamenti on Nov 19, 2015
Latest reply on Nov 19, 2015 by David E Seymour

Hi,

I found a problem in the OSA_TimeDelay() function defined in "KSDK_1.3.0/platform/osa/src/fsl_os_abstraction_bm.c".

 

void OSA_TimeDelay(uint32_t delay)

{

    uint32_t currTime, timeStart;

 

    timeStart = OSA_TimeGetMsec();

 

    do {

        currTime = OSA_TimeGetMsec(); /* Get current time stamp */

    } while (delay >= OSA_TimeDiff(timeStart, currTime));

}

 

The condition inside the while loop makes the delay always 1 ms greater (because of the equality test) than the parameter passed to the function.

 

timer tick | delay = 3

0          | timeStart = 0

           | 3 >= 0 // true, busy wait

1          | 3 >= 1 // true, busy wait

2          | 3 >= 2 // true, busy wait

3          | 3 >= 3 // true, busy wait

4          | 3 >= 4 // false, exit

 

Instead it should be:

while (delay > OSA_TimeDiff(timeStart, currTime));

 

Best Regards,

Derek

Outcomes