Good day
I have a PIT timer that generates an interrupt every ms.
I would like to adjust the period on a regular basis in my program.
I tried calling the PIT_SetTimerPeriod() function, but this seems to have no effect.
I think that perhaps the timer must be stopped before the period can be adjusted.
Is there a way around this? Is it possible to change the timer period while the timer is running so that it doesn't lose it's counter?
I would like to delay the interrupt from occurring slightly sometimes, and sometimes have the interrupt happen sooner, preferably without having to de-initialise and re-initialise it every time.
Kind regards
Solved! Go to Solution.
Update: I figured it out.
First, store the number of ticks already counted (if necessary) by subtracting the previous period by PIT_GetCurrentTimerCount(...).
Then call PIT_StopTimer(...) to stop the timer.
Then change the period with PIT_SetTimerPeriod(...).
Then call PIT_StartTimer(...) to restart the timer with the new period.
Update: I figured it out.
First, store the number of ticks already counted (if necessary) by subtracting the previous period by PIT_GetCurrentTimerCount(...).
Then call PIT_StopTimer(...) to stop the timer.
Then change the period with PIT_SetTimerPeriod(...).
Then call PIT_StartTimer(...) to restart the timer with the new period.