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.

Sys/Bios - periodic clock - called function time is larger that the period clock

Guru 10750 points

Hi All,

I have defined a 5mS periodic clock which call a function, usually the function takes less than 1mS but every 30mS the function takes 20mS, I was expecting that as the periodic clock is based on HW interrupt than when the function is larger than the periodic clock than it will lose a few function calls but what I have seen is that the function is being call according to the 5mS which means that after the 20mS the function is called a few times (according to the number of missed 5mS periods) why is that?

Thanks,

HR

  • HR,

    What you’ve observed is the expected behavior.  If there is a delay that holds off Clock from being able to process ticks, it will ‘catch up’ for ticks that were delayed.  (The alternative would be to ‘drop’ ticks, which could be a significant problem for many applications.)  I looked to see if I could find this documented somewhere and could not find anything.  I will file a defect report to get this documented…

    Is it the case that you know when the function will require 20msec to run?  If so, can you post a Swi or a Task to do that processing, rather than doing it as at Clock function?  The catch up mechanism you observed is there to avoid missing ticks, but it wasn’t intended to be used routinely for this type of situation.  Also, if you add other Clock objects to your application with smaller periods, then this 20msec function will cause those other Clock objects from being serviced properly.

    Scott

  • Scott,

    I did the test to check the system behavior to see what's happened in case of missing period tick,  so where the system counts the number of tics? does the system checks the time different between the two periodic time and in case of overflow than it calls the function the number of times it was supposed to call, is this correct?

    Many Thanks,

    HR

  • HR,

    There are a few configuration scenarios, but the typical case is that ticks are incremented in the related Timer ISR function, and then that ISR function posts a Swi used by Clock to service the list of Clock objects.  The Swi function (called Clock_workFunc()) is where the catchup is done, considering the current tick count, and the number of times the Swi was posted.

    Scott

  • Scott,

    OK, Thank you for the clarification,

    HR