Change PIT Timer Period While Running

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Change PIT Timer Period While Running

ソリューションへジャンプ
1,635件の閲覧回数
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,629件の閲覧回数
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,630件の閲覧回数
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.