///////////////////////////////////////////////////////////////////// // function: Wait_uSeccond // // Descript: Spin in a delay loop for delay microseconds // Note: (1) Timer-2 does not trig a interrupt. // (2) The MAX time is 57.2662306 seconds at CPU clock 600 MHz. // (3) 1uS = 75 cycle. ////////////////////////////////////////////////////////////////////// void Wait_uSeccond( Uint32 ui32Delay) { Uint32 cnt; TIMER_Config cfgTimer2;
// save Timer2 old settings TIMER_getConfig( hTimer2, &cfgTimer2);
cnt = 75*ui32Delay;
// clear the timer count register TIMER_setCount( hTimer2, 0x00000000);
// resume the timer2 TIMER_resume( hTimer2);
// wait until time=delay while( TIMER_getCount( hTimer2) < cnt);
// Reconfigure Timer2 with old settings TIMER_config( hTimer2, &cfgTimer2); }