Change PIT Timer Period While Running

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

Change PIT Timer Period While Running

跳至解决方案
1,068 次查看
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 项奖励
回复
1 解答
1,062 次查看
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.

在原帖中查看解决方案

1 回复
1,063 次查看
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.