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.

Z-Stack:osal_GetSystemClock problem

Other Parts Discussed in Thread: Z-STACK, CC2430

Hello,

I'm using CC2430 and Z-Stack 1.4.3-1.2.1.

When I try to calculate the time my program spend,I use the OSAL API:osal_GetSystemClock(),

But it seem to me that the clock value doesn't refresh.

Code is listed as follow,and LCD gives the same value of Time_Tick_Begin and Time_Tick_End:

Time_Tick_Begin = osal_GetSystemClock();
halWaitMs(100);
Time_Tick_End = osal_GetSystemClock();
    
HalLcdWriteValue( Time_Tick_Begin, 10, HAL_LCD_LINE_2 );
HalLcdWriteValue( Time_Tick_End, 10, HAL_LCD_LINE_3 );

Hope somebody can help me.

Thank you.

Peter

  • Your observation is entirely expected. The OSAL system clock gets updated at the beginning of the task loop (infinite) in osal_start_system(). This means that the time value returned from a call to osal_GetSystemClock() will only be updated when tasks return control to OSAL. So, the code snippet you show in your example, gets the OSAL time just before your task started to run, waits 100 milliseconds, and then gets another copy of the same time.

  • Thanks for your reply .

    Is there a mathod to update the system clock  manually or a way to calculate the time my program comsum in Z-Stack?

    I know in CCS there is a tool like clock profile which can accomplish this work,but is there a similar tool in IAR?

    Thanks.

    Peter

  • Zuopeng,

    This is not highly recommended because I'm not sure how it may affect the overall OSAL/MAC performance, but you can try calling macMcuPrecisionCount() that provides 320us timer tick.

    - Cetri