Trouble resetting Periodic Interrupt Timer (PIT)

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

Trouble resetting Periodic Interrupt Timer (PIT)

1,977件の閲覧回数
ignisuti
Contributor IV

I’m trying to synchronize this timer module with another time source.

According to the documentation, I can restart this timer by simply disabling and re-enabling it. I've set a break point immediately before and after the code listed below. I don’t think this is working as intended because the timer’s Current Value is decremented slightly and nowhere near the Reload Value.

PIT_TCTRL_REG( PIT_BASE_PTR, 0 ) &= ~PIT_TCTRL_TEN_SHIFT;

PIT_TCTRL_REG( PIT_BASE_PTR, 0 ) |=  PIT_TCTRL_TEN_SHIFT;

Note: I’m referencing Figure 38-23 of the Document K10P144M100SF2RM Rev. 6, Nov 2011

Please let me know if you have any suggestions.

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 返信

1,213件の閲覧回数
mjbcswitzerland
Specialist V

Hi

I think that you may need to write to the LDVAL register when the PIT is disabled so that it restarts.

This is an extract from the PIT code from the uTasker project which can be used as a single-shot / retriggerable or periodic timer - it was necessary to disable operation if its value was to be reset/retriggered - without this it doesn't react.

if (PIT_settings->mode & (PIT_SINGLE_SHOT | PIT_RETRIGGER)) {  // single shot always behaves as retriggerable - periodic change at next timeout by default but can be forced with PIT_RETRIGGER                

    ptrCtl->PIT_TCTRL = 0;    // disable PIT so that it can be retriggered if needed

}

ptrCtl->PIT_LDVAL = PIT_settings->count_delay;               // load interval value

ptrCtl->PIT_TFLG  = PIT_TFLG_TIF;                            // clear pending interrupts

ptrCtl->PIT_TCTRL = ulCommand;                               // start PIT with interrupt enabled, when handler defined

Regards

Mark

http://www.uTasker.com