Change PIT Timer Period While Running

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

Change PIT Timer Period While Running

Jump to solution
646 Views
D_TTSA
Contributor V

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

0 Kudos
1 Solution
640 Views
D_TTSA
Contributor V

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.

View solution in original post

1 Reply
641 Views
D_TTSA
Contributor V

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.