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

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

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

1,027 次查看
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

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

689 次查看
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