simply function call periodically on MCF52235

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

simply function call periodically on MCF52235

1,500件の閲覧回数
sev
Contributor I
I'm a begginer on this board.
I would like to call my function for example every 10ms.
I don't at all the way I have to take. Does anyone help me: DMA timer, PIT, GPT, ...
thanks a lot for your help.


Message Edited by sev on 2008-04-21 09:49 AM
ラベル(1)
0 件の賞賛
返信
1 返信

532件の閲覧回数
mjbcswitzerland
Specialist V
Hi sev

A PIT (periodic interrupt timer) is generally used for such work.

It is very easy to set up but does require the interrupt controller to also be set up correctly. It may be easier for you to start with a complete project (see the uTasker project which is free for non-commercial use). Below  is the PIT0 code to configure a periodic interrupt (TICK_RESOLUTION would be 10 in your case) and then handle the interrupt, calling a function names fnRtmkSystemTick():

// calculate the settings//#define REQUIRED_MS ((1000/TICK_RESOLUTION))                             // the TICK frequency we require in kHz#if TICK_RESOLUTION > 4  #if TICK_RESOLUTION > 64    #define TICK_DIVIDE (((BUS_CLOCK/2/32768) + REQUIRED_MS/2)/REQUIRED_MS) // the divide ratio required (32k prescaler assumed)    #define PIT_PRESCALE PIT_PRESCALE_32K  #else    #define TICK_DIVIDE (((BUS_CLOCK/2/4096) + REQUIRED_MS/2)/REQUIRED_MS)  // the divide ratio required (4k prescaler assumed)    #define PIT_PRESCALE PIT_PRESCALE_4K  #endif#else  #define TICK_DIVIDE (((BUS_CLOCK/2/1048) + REQUIRED_MS/2)/REQUIRED_MS)    // the divide ratio required (1k prescaler assumed)  #define PIT_PRESCALE  PIT_PRESCALE_1K#endif// TICK uses PIT 0//extern void fnStartTick(void){    PIT_PCSR_0 = (PIT_PRESCALE | PIT_DBG | PIT_OVW | PIT_PIF | PIT_RLD); // prepare for load    PIT_PMR_0 = (TICK_DIVIDE - 1);                                       // load interval value    fnSetIntHandler(PIT0_VECTOR, (unsigned char *)_RealTimeInterrupt);    IC_ICR_0_55 = TICK_INTERRUPT_PRIORITY;                               // define interrupt level and priority    IC_IMRH_0 &= ~(PIT_0_PIF_INT_H);                                     // unmask interrupt source    IC_IMRL_0 &= ~(MASK_ALL_INT);                                        // clear global mask    PIT_PCSR_0 = (PIT_PRESCALE | PIT_DBG | PIT_OVW | PIT_PIF | PIT_RLD | PIT_PIE | PIT_EN); // start PIT with interrupt enabled}static __interrupt__ void _RealTimeInterrupt(void){  PIT_PCSR_0 = (PIT_PRESCALE | PIT_DBG | PIT_OVW | PIT_PIF | PIT_RLD | PIT_PIE | PIT_EN); // reset interrupt request flag  fnRtmkSystemTick();                                                    // operating system tick}

 Regards

Mark

www.uTakser.com




0 件の賞賛
返信