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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

780 Views
derek_ik
Contributor I

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

Labels (1)
0 Kudos
1 Reply

442 Views
DavidS
NXP Employee
NXP Employee

Hi Derek,

Thank you fro reporting this.

I have submitted it to our KSDK software development team.

It is reported as KPSDK-7957

Regards,

David